急!急!急! Tomcat4.0莫名其妙的自动关闭
急!急!急!Tomcat4.0每运行几天就会莫名其妙的自动关闭, 有时候首页可以进入,但是到连接ODBC用户登陆时偶尔会出现Exception : general error . 的错误(大多数时候不会报错). 听说是sql中的连接Connection 对象没有在运行完毕之后关闭 , 但是我关闭连接对象之后还是会出现异常现象 . 请各位帮帮忙 .
以下是登陸用的部分Code :
<%
Connection conn ;
Statement stmt ;
ResultSet rs ;
String temp_userid,temp_password,login_userid,sql,message;
message="";
temp_userid = "";
temp_password = "";
login_userid = "";
if(request.getParameter("login")!=null){
try{
temp_userid = request.getParameter("userid");
temp_password = request.getParameter("password");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:user","","");
stmt = conn.createStatement();
sql = "SELECT * FROM c_user_t WHERE user_id='" + temp_userid + "' AND pass_word='" + temp_password + "'";
rs = stmt.executeQuery(sql);
}catch(Exception e){
out.println("<br>"+"Sorry");
out.println("<br>Error get database connection,process terminated.<br>Please try again or contact administrator.");
out.println("<br>Error message:" +e);
return;
}
if (rs.next()){
login_userid = rs.getString("user_id");
if (stmt!=null){stmt.close();}
if (conn!=null){conn.close();}
message = login_userid;
response.sendRedirect("mainframe.jsp");
session.setAttribute("username",temp_userid);
session.setAttribute("version","EN");
return;
}else{
message = "Invalid user ID or password!";
}
}
if(temp_userid==null){
temp_userid="";
}
%>
......
<%conn.close();%>