日期:2014-05-19  浏览次数:20645 次

为什么捕获不到NullPointerException异常?下面有代码和一部分异常信息,我做的是oracle和java的编程
public List<ShowScore> show_score(int stuid){
List<ShowScore> showscores = new ArrayList<ShowScore>();
Connection conn = DBUtil.createConnection();
String sql = "{call pack_college_mat.show_score(?,?,?,?,?,?,?,?,?,?,?,?)}";
CallableStatement cs;
try {
cs = conn.prepareCall(sql);
cs.setInt(1, stuid);
cs.registerOutParameter(2, OracleTypes.NUMBER);
cs.registerOutParameter(3, OracleTypes.VARCHAR);
cs.registerOutParameter(4, OracleTypes.NUMBER);
cs.registerOutParameter(5, OracleTypes.NUMBER);
cs.registerOutParameter(6, OracleTypes.NUMBER);
cs.registerOutParameter(7, OracleTypes.NUMBER);
cs.registerOutParameter(8, OracleTypes.NUMBER);
cs.registerOutParameter(9, OracleTypes.NUMBER);
cs.registerOutParameter(10, OracleTypes.VARCHAR);
cs.registerOutParameter(11, OracleTypes.NUMBER);
cs.registerOutParameter(12, OracleTypes.VARCHAR);
cs.execute();
showscores.add(new ShowScore(new BigDecimal(cs.getObject(2).toString()).intValue(),(String)cs.getObject(3),new BigDecimal(cs.getObject(4).toString()).floatValue(),new BigDecimal(cs.getObject(5).toString()).floatValue(),new BigDecimal(cs.getObject(6).toString()).floatValue(),new BigDecimal(cs.getObject(7).toString()).floatValue(),new BigDecimal(cs.getObject(8).toString()).floatValue(),new BigDecimal(cs.getObject(9).toString()).intValue(),(String)cs.getObject(10),new BigDecimal(cs.getObject(11).toString()).intValue(),(String)cs.getObject(12)));
return showscores;
} catch (SQLException e) {
e.printStackTrace();
return null;
}catch (Exception e){
return null;
}
}
————————————————————————
严重: dwr-invoker: Method execution failed:
java.lang.NullPointerException
at com.xiaomai.dao.FunctionDao.show_result(FunctionDao.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

------解决方案--------------------
at com.xiaomai.dao.FunctionDao.show_result(FunctionDao.java:134)
你贴出来的代码是show_score。
应该把异常的那句贴出来看看。