Posted By:
Gerard_Martinelli
Posted On:
Saturday, June 25, 2005 04:54 AM
Sometimes, I got the "Connection pool exhausted" message when I want to get a new connection to MYSQL Database. After checking and rechecking my code, I have not found any part where I could leave my servlet without closing the connection (I always use a finally clause). However, I'm wondering what is happening in the case below : public class Test1 extends HttpServlet { private javax.sql.DataSource ds=null; protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { try { con = ds.getConnection(); MyBean ad = new MyBean(con); } catch (Exception ex) { .....}
More>>
Sometimes, I got the "Connection pool exhausted" message when I want to get a new connection to MYSQL Database.
After checking and rechecking my code, I have not found any part where I could leave my servlet without closing the connection (I always use a finally clause).
However, I'm wondering what is happening in the case below :
public class Test1 extends HttpServlet
{
private javax.sql.DataSource ds=null;
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
{
try
{
con = ds.getConnection();
MyBean ad = new MyBean(con);
}
catch (Exception ex) { .....}
finally
{
if (con != null)
{
try {con.close();}
catch (SQLException e) {}
}
}
}
}
What is going on if the bean "MyBean" does not close Statements and ResultSets ? Is the con.close() accepted and processed ?
Is there any way to get the number of connections available (just for tracing purpose) ?
Thanks
Gerard
<<Less