users@glassfish.java.net

Re: Error in allocating a connection

From: <glassfish_at_javadesktop.org>
Date: Thu, 02 Sep 2010 08:23:44 PDT

The application class method that calls getConnection() method of this connection-adapter has finally method that again calls closeConnection() method

sample is here

Class someclass {

    public void performSomeDBOperations() {
   
          Connection nativeConnection = null;
          try {
                 nativeConnection = this.getConnectionAdapter().getConnection();
                 // perform all DB operations
          }
          catch(Exception e) {
                if (nativeConnection != null) { nativeConnection.rollback (); }
                logger.error
                throw e;
          }
          finally {
                     if (cs != null) { cs.close(); }
                     if (rs != null) { rs.close(); }
                     this.getRmsConnection().closeConnection();
          }
}

As per the glassfish developer guide
con = dataSource.getConnection(sunConn); // this con object should never be closed
so i am having another method that close sunConn object.
[Message sent by forum member 'sapnasamdavid']

http://forums.java.net/jive/thread.jspa?messageID=481709