Hi developers,
I have bean managed Entity bean
I do trying to get 2 oracle connections like:
try
{
DataSource ds = (DataSource)new
InitialContext().lookup("java:comp/env/jdbc/OraclePool");
Connection aCon1 = ds.getConnection();
Connection aCon2 = ds.getConnection();
}
Rezult is:
[EMailApplication] java.sql.SQLException: ORA-02089: COMMIT is not allowed in a
subordinate session
I think what if i do trying to get second db connection from the pool in the same EJB
transaction the first one should be returned.
I have looked into source code i found this:
file: OraclePool.java
function: public Object getObject()
while(true) {
Iterator it = objects.values().iterator();
while(it.hasNext()) {
ObjectRecord rec = (ObjectRecord)it.next();
if(!rec.isInUse()) {
}
.....
}//end while
result = createNewObject(true);
dont u think could be done better:
1. then connection is created it is stored association db connection-transaction
2. when request for new connection happens it should be checked if db connection is in
use AND IF IT IS IN USE check IF THE SAME TRANSACTION
ASKING FOR CONNECTION. If transaction the same - the same db connection returned is
transactions different new db connection is created.
Maybe i dont understand somethink but now creating 2 diferent connections for the same
EJB transaction sound not very flexible.
D&D