[jboss-user] [JBossCache] - Re: Urgent- Socket error when adding object to DB using JDBC

manik.surtani@jboss.com do-not-reply at jboss.com
Tue Oct 10 17:42:39 EDT 2006


Ah, here's a reason why - are you running your test within a transaction?

Non-tx-related calls call cf.close(), which results in:


  |     public void close(Connection con)
  |       {
  |          if(con != null && con != connection.get())
  |          {
  |             try
  |             {
  |                con.close();
  |                if(log.isTraceEnabled())
  |                {
  |                   //log.trace("closed non tx connection: " + con);
  |                }
  |             }
  |             catch(SQLException e)
  |             {
  |                log.warn("Failed to close connection: " + e.getMessage());
  |             }
  |          }
  |       }
  | 
  | 

So the connection is only closed if it is NOT the one in ThreadLocal, otherwise it is kept open.

If you set the connection in ThreadLocal (and even in getConnection() for that matter, rather than prepare()) these connections will not get closed and you have some sort of a connection pool going, based on the number of processor threads.  I presume this could exhaust your DB backend if these are high.

Could you confirm whether you're using txs in your test?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3977381#3977381

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3977381



More information about the jboss-user mailing list