IDEMPIERE-1235 Add API to support the sharing of non-transactional connection within a single execution thread. Added simple sanity check ( isclosed ) for connection.

This commit is contained in:
Heng Sin Low 2013-08-05 20:48:09 +08:00
parent 40e569e0cb
commit 25d58a3f8d
1 changed files with 11 additions and 9 deletions

View File

@ -38,15 +38,17 @@ public class AutoCommitConnectionBroker {
*/
public static Connection getConnection() {
ConnectionReference connReference = threadLocalConnection.get();
if (connReference != null) {
connReference.referenceCount++;
return connReference.connection;
} else {
Connection connection = DB.createConnection(true, false, Connection.TRANSACTION_READ_COMMITTED);
connReference = new ConnectionReference(connection);
threadLocalConnection.set(connReference);
return connection;
}
try {
if (connReference != null && !connReference.connection.isClosed()) {
connReference.referenceCount++;
return connReference.connection;
}
} catch (SQLException e) {}
Connection connection = DB.createConnection(true, false, Connection.TRANSACTION_READ_COMMITTED);
connReference = new ConnectionReference(connection);
threadLocalConnection.set(connReference);
return connection;
}
/**