我正在使用BoneCp连接池。我有一个问题,即在哪里指定JDBC连接对象,以便它不应该给ResultSet关闭或Connection关闭等错误。在哪里定义servlet中的Connection,Statement,ResultSet
我做的,如下图所示:(代码段)
public Class GetTable extends HttpServlet {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
protected void doPost(HttpServletRequest req,HttpServletResponse res)
{
con = ConnectionManager.getConnectionPool().getConnection();
//initializing stmt,rs
//close con,stmt,rs using try and catch
}
}
这是很好的方式,或者有定义所有JDBC里面doPost
对象?
对于每个请求创建一个新的servlet实例,那么我如何管理JDBC对象没有错误。
相关/重复:http://stackoverflow.com/q/3106452 – BalusC