help:对ResultSet进行操作时出现java.lang.NullPointerException错误?
代码:
Connection conn=null;
Statement stm=null;
GetDatabaseConnection getConn=new GetDatabaseConnection("tabxx");
conn=getConn.getConnection();
//查询现有服务类型
String sqlServiceType="select distinct ServiceType from aaa"+
" where UserState=1 or UserState=0";
//查询地区代码
String sqlAreacode="select distinct areacode from aaa"+
" where UserState=1 or UserState=0";
stm=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rsServiceType = stm.executeQuery(sqlServiceType);
ResultSet rsAreacode = stm.executeQuery(sqlAreacode);
//服务的数目
rsServiceType.last();
int serviceNum=rsServiceType.getRow();
rsServiceType.beforeFirst();//
用jsp调用时出错:
500 Servlet Exception
java.lang.NullPointerException
at oracle.jdbc.driver.ScrollableResultSet.cacheRowAt(ScrollableResultSet.java:2086)
at oracle.jdbc.driver.ScrollableResultSet.isValidRow(ScrollableResultSet.java:2060)
at oracle.jdbc.driver.ScrollableResultSet.isEmptyResultSet(ScrollableResultSet.java:2027)
at oracle.jdbc.driver.ScrollableResultSet.last(ScrollableResultSet.java:504)
at testChart.createDataBean.getTotalData(createDataBean.java:57)
at _jsp._boat._indexofchartdemo__jsp._jspService(/boat/IndexOfChartDemo.jsp:21)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.pageservice(Page.java:571)
at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:155)
at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:211)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:177)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:221)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:263)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:323)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:430)
at com.caucho.util.ThreadPool.run(ThreadPool.java:377)
at java.lang.Thread.run(Thread.java:534)
--------------------------------------------------------------------------------
Resin-3.0.7 (built Wed, 24 Mar 2004 04:28:45 PST)
我测试了,数据库已经连上了
哪位大虾帮帮忙?thanks!!!