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:
parent
40e569e0cb
commit
25d58a3f8d
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue