ResultSet is closed!!!为什么?
<%@ page contentType= "text/html; charset=GBK " %>
<html>
<head>
<title> connect the db </title>
</head>
<%@ page import= "java.sql.* "%>
<body bgcolor= "#ffffff ">
<%
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
String url= "jdbc:odbc:JSPuser "; // message_DSN 为你的用户数据源名称;
String user= " ";
String password= " "; // 用户名和密码在此都设为空;
String name;
String pwd;
String c;
name=request.getParameter( "name ");
pwd=request.getParameter( "pwd ");
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String sql= "select * from TBuser where name= ' "+name+ " '; ";
String pd= "select * from TBuser where password= ' "+pwd+ " '; ";
ResultSet rs1=stmt.executeQuery(pd);
ResultSet rs=stmt.executeQuery(sql);
%>
<%
if ((rs1.getString(2)).equals(rs.getString(2)))
out.println( "OK ");
else
out.println( "Error ");
%>
<%rs.close();
rs1.close();
stmt.close();
conn.close();
%>
</body>
</html>
以上是JSP代码。。。
问题是出现了
javax.servlet.ServletException: ResultSet is closed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.JSPco_jsp._jspService(JSPco_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: ResultSet is closed
sun.jdbc.odbc.JdbcOdbcResultSet.checkOpen(JdbcOdbcResultSet.java:6647)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:256)
org.apache.jsp.JSPco_jsp._jspService(JSPco_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
高手帮帮 怎么改
------解决方案--------------------客气了 我也是刚开始做J2EE的 也刚来CSDN不久 大家互相学习嘛 我们公司白天不让上QQ和MSN 我晚上加你吧