在关闭连接的时候一直出错, 请大侠指点。
org.apache.jasper.JasperException: An exception occurred processing JSP page /news/login.jsp at line 2623: out.print("用户名或密码错误!");
24: }catch(Exception ce){System.out.print(ce.toString());}
25: finally{
26: con.close();
27: pst.close();
28: rst.close();
29: }原代码如下:<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.sql.*"%>
<%
String username,userpwd;
username=request.getParameter("username");
userpwd=request.getParameter("userpwd");
Connection con=null;
PreparedStatement pst=null;
ResultSet rst=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con=DriverManager.getConnection("jdbc:sqlserver://localhost;database=News","yjw757174266","yejianwen");
pst=con.prepareStatement("select * from usertabel where username=? and userpwd=?");
pst.setString(1,username);
pst.setString(2,userpwd);
rst=pst.executeQuery();
if(rst.next()){
session.setAttribute("username",username);
session.setAttribute("loged","true");
response.sendRedirect("main.jsp");
}
else
out.print("用户名或密码错误!");
}catch(Exception ce){System.out.print(ce.toString());}
finally{
con.close();
pst.close();
rst.close();
}
%>
感激不尽。
org.apache.jasper.JasperException: An exception occurred processing JSP page /news/login.jsp at line 2623: out.print("用户名或密码错误!");
24: }catch(Exception ce){System.out.print(ce.toString());}
25: finally{
26: con.close();
27: pst.close();
28: rst.close();
29: }原代码如下:<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="java.sql.*"%>
<%
String username,userpwd;
username=request.getParameter("username");
userpwd=request.getParameter("userpwd");
Connection con=null;
PreparedStatement pst=null;
ResultSet rst=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con=DriverManager.getConnection("jdbc:sqlserver://localhost;database=News","yjw757174266","yejianwen");
pst=con.prepareStatement("select * from usertabel where username=? and userpwd=?");
pst.setString(1,username);
pst.setString(2,userpwd);
rst=pst.executeQuery();
if(rst.next()){
session.setAttribute("username",username);
session.setAttribute("loged","true");
response.sendRedirect("main.jsp");
}
else
out.print("用户名或密码错误!");
}catch(Exception ce){System.out.print(ce.toString());}
finally{
con.close();
pst.close();
rst.close();
}
%>
感激不尽。
解决方案 »
- SSH2+JSON延迟加载问题求解
- 关于<img>的问题
- 求chinaren社区技术解决方案
- 两页面间多个参数传值问题
- 一个奇怪的问题,郁闷中。。。大家发表一下.
- sqlserver7的jdbc-odbc如何配置?
- tomcat 怎么设置servlet?
- 请问这是什么原因?ServletRequest has been deprecated,谢谢
- 关于ssh中多个数据源公用同一个sessionFactory问题
- 部署WebSphere问题,求救啊!在线等
- 数据库中setString()的使用
- 用XDocle生成struts-config.xml配置文件,因为工程用到Action是继承DispatchAction,生成配置文件生成不了注释文件内容
27: pst.close();
28: rst.close();
这个关闭的顺序反了
这行代码去了 试一试
con.close();
pst.close();
rst.close();
}
你最后都没有判断就关闭。如果已经关闭了再执行关闭的操作不是会报错么?