I am using BoneCp connection pool. I have a question that where to specify JDBC connection objects such that It should not give errors like ResultSet is closed or Connection is closed.
I am doing as shown below:(code snippet)
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
}
}
Is this good way or I have to define all JDBC objects inside doPost
?
For every request a new Instance of servlet is created then how I have to manage JDBC objects without errors.