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() {
|
public static Connection getConnection() {
|
||||||
ConnectionReference connReference = threadLocalConnection.get();
|
ConnectionReference connReference = threadLocalConnection.get();
|
||||||
if (connReference != null) {
|
try {
|
||||||
connReference.referenceCount++;
|
if (connReference != null && !connReference.connection.isClosed()) {
|
||||||
return connReference.connection;
|
connReference.referenceCount++;
|
||||||
} else {
|
return connReference.connection;
|
||||||
Connection connection = DB.createConnection(true, false, Connection.TRANSACTION_READ_COMMITTED);
|
}
|
||||||
connReference = new ConnectionReference(connection);
|
} catch (SQLException e) {}
|
||||||
threadLocalConnection.set(connReference);
|
|
||||||
return connection;
|
Connection connection = DB.createConnection(true, false, Connection.TRANSACTION_READ_COMMITTED);
|
||||||
}
|
connReference = new ConnectionReference(connection);
|
||||||
|
threadLocalConnection.set(connReference);
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue