ODBC 驱动程序管理器] 无效的游标状态 的问题
我用的tomcat 7.0,eclipse 8.5,已经把class12.jar放到tomcat的lib目录下,oracle是9.2,表login的列we 和ss都是
varchar2(10)类型。在执行下列代码时:
..........................................
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:bksfhcxt";
String user="system";
String password="oracle2";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement();
String sql="select * from LOGIN";
ResultSet rs=stmt.executeQuery(sql);
if (rs !=null){out.println("rs.getString(3)");}
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
...................................................
页面能正确显示 rs.getString(3) 字符出来,
但在执行下面语句时:
........................................................
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:bksfhcxt";
String user="system";
String password="oracle2";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement();
String sql="select * from LOGIN";
ResultSet rs=stmt.executeQuery(sql);
//if (rs !=null){out.println("rs.getString(3)");}
while(rs.next()){%>
<%=rs.getString(1)%>
<%=rs.getString(2)%>
<%}%>
<table>
<tr>
<td>员工号</td>
<td>姓名</td>
</tr>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
</tr>
</table>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
...............................................................
则报以下错误:
............................................................
type Exception report
message
An exception occurred processing JSP page /index.jsp at line 24
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 24
21: <td>濮撳悕</td>
22: </tr>
23: <tr>
24: <td><%=rs.getString(1)%></td>
25: <td><%=rs.getString(2)%></td>
26:
27: </tr>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException:
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。