每当我关闭tomcat服务器,就会出现的问题,如下图
Dao包下的stuDao类调用JDBCUtils类的查询用户信息方法,因为我有在finally里面调用了JDBCUtils.close()方法,为什么还出现线程未关闭的问题,很困惑
public class StuDao {
Connection cn = null;
PreparedStatement pr = null;
ResultSet resultSet = null;
public User selectUserBySidAndPswd(String sid, String pswd){
User user = null;
try {
cn = JDBCUtils.getConnection();
String sql = "select * from t_user where sid = ? and password = ?";
pr = cn.prepareStatement(sql);
pr.setString(1,sid);
pr.setString(2,pswd);
resultSet = pr.executeQuery();
while(resultSet.next()){
user = new User();
user.setSid(resultSet.getString("sid"));
user.setPassword(resultSet.getString("password"));
}
} catch (Exception e) {
e.printStackTrace();
}finally {
JDBCUtils.close(resultSet,pr,cn);
}
return user;
}
}
JDBCUtils类
druid的配置文件如下: