public void destroy(){
System.out.println("destroy the servlet");
//super.destroy();
int temp=Integer.parseInt(getServletContext().getAttribute("countNum").toString());  //获取application的值
try {
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost/webdb","iheng","iheng");
state=connection.createStatement();
state.executeQuery("update table_1 set WebCount="+temp+" where id='102'");    //将获得的值写入数据库
connection.close();
} catch (ClassNotFoundException | SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}问题代码如上,据网上说,当Tomcat(我用的服务器是Tomcat)关闭的时候,就会自动调用Destroy()方法,但是我关掉Tomcat之后,查询数据库,数据库里面的字段值并没有被更新,这是什么原因呢? 是Destroy()没有正确被调用么?求知情者指教~~~~~~Servlet数据库TomcatJava