日期:2014-05-17 浏览次数:20825 次
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();
}
}