在关闭连接的时候一直出错, 请大侠指点。
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();
}
%>
感激不尽。
解决方案 »
- struts1中重写validate方法如何获取到资源文件
- 求一算法,判断数组中是否有重复数据
- java web 程序打包 求解高手
- 请教高手解惑……关于框架、关于海量数据、web开发
- 求一个基于java的web报表引擎,最好是免费的
- 请教如何解决中文搜索的乱码问题?
- 网站开发流程是怎么样的?
- weblogic不能加载用户定义的filter,请高手指点!
- tomcat4.1数据库连接池
- 服务器的配置问题!
- 数据库中setString()的使用
- 用XDocle生成struts-config.xml配置文件,因为工程用到Action是继承DispatchAction,生成配置文件生成不了注释文件内容
27: pst.close();
28: rst.close();
这个关闭的顺序反了
这行代码去了 试一试
con.close();
pst.close();
rst.close();
}
你最后都没有判断就关闭。如果已经关闭了再执行关闭的操作不是会报错么?