users@glassfish.java.net

Re: Glassfish DB Connection Pool Bug in Local Transaction Case

From: <glassfish_at_javadesktop.org>
Date: Wed, 27 Jun 2007 12:58:24 PDT

Jagdish,


>UserTransaction uTx = entityContext.getUserTransaction();
>uTx.begin();
>con1 = dataSource.getConnection();
>doDBOperation() using connection-1
>con1.close();
>con2 = dataSource.getConnection();
>doDBOperation() using connection-2
>uTx.commit();
>con2.close();

This is not the case we are taking about, this will always work even in local tx with CMT because con1.close() will mark the ResourceHandle as not busy. Next getConnection() call will return the ResourceHandle in the J2EETransaction.

The case that is interesting is here:

Ejb1.method() {
con1 = dataSource.getConnection("jdbc/dbconn");
doSomething();
// could be another method in same bean or another EJB with tx marked REQUIRED, hence that call will run in the same transaction that this method is running in.
method2();
con1.close();
}

[Ejb2 or Ejb1].method2() {
con2 = dataSource.getConnection("jdbc/dbconn");
doSomething();
con2.close();
}

So the case is that of nested getConnection() not sequential getConnection() call.

I am pretty sure that even in the BMT case in the code snippet you mention, Glassfish will behave the same.

--
Sanjay
[Message sent by forum member 'sanjaydwivedi' (sanjaydwivedi)]
http://forums.java.net/jive/thread.jspa?messageID=224318