关于JSP里查询语句SQL的一个简单问题!help!
源代码:
<%Class.forName( "com.ibm.as400.access.AS400JDBCDriver ").newInstance();
//连接数据库
String url= "jdbc:AS400://A46cm:23/DATA1 ";
String user= " ";
String password= " ";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql1= "select * from table1 ";
String sql2= "select * from table2 ";
ResultSet rs1=stmt.executeQuery(sql1);
ResultSet rs2=stmt.executeQuery(sql2);
while(rs1.next()) {%>
<table>
<tr>
<td>
Total Qty: <%=rs1.getString( "T1 ")%>
</td> </tr>
<%}%>
<%
if(!rs1.next())
out.print( "没有找到! ");%>
<%rs1.close();
stmt.close();
conn.close();
%>
我在jsp里连接数据库,然后查询database,一开始只定义一个sql1语句查询table1表单,可以运行,后来加了一句,sql2语句,想查询table2的表单,就报错误:
javax.servlet.ServletException: Cursor state not valid.
这是咋回事阿?难道一个jsp里只能有查一个表单?
Help!!!!!!
------解决方案--------------------Statement stmt2=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs2=stmt2.executeQuery(sql2);