tomcat+mysql数据库连接报错
严重:The web application [/myWebSite] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it.This is very likely to create a memory leak.
代码如下:
package com.uestc;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class LoginCl extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
PrintWriter pw = res.getWriter();
HttpSession hs = req.getSession(true);
String u = req.getParameter("user");
String p = req.getParameter("passwd");
String error = "login in again please";
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/spdb?user=root&password=root");
stmt = conn.createStatement();
rs = stmt.executeQuery("select passwd from users where username='"+u+"' limit 0,1");
if(rs.next()) {
String passwd = rs.getString(1);
if(passwd.equals(p)) {
hs.setAttribute("pass","ok");
res.sendRedirect("wel?user="+u+"&passwd="+p);
} else {
res.sendRedirect("login?error="+error);
}
}
else {
res.sendRedirect("login?error="+error);
}
}catch(Exception ex) {
ex.printStackTrace();
}finally{
try{
if(rs!= null) {
rs.close();
}
if(stmt != null) {
stmt.close();
}
if(conn != null) {
conn.close();
}
}catch(Exception ex) {
ex.printStackTrace();
}
}
}
public void doPost(HttpServletRequest req,HttpServletResponse res) {
this.doGet(req,res);
}
}
请教这是什么错误?