http://docs.oracle.com/cd/E24329_01/web.1211/e24376/phys_conr.htm#JDBCP1037
http://docs.tpu.ru/docs/oracle/en/fmw/11.1.1.6.0/apirefs.1111/e13941/toc.htm
There are special tasks when we need to explicitly close physical connection to the database: clean errors on the connection for example.
General standard solution does not exist but for WebLogic data source we can do the following:
1. Ensure that "Remove Infected Connections Enabled" option is set to true; true is default.
2. For dismissing connection from a connection pool call ( (WLConnection) connection).getVendorConnection() and close the pooled connection:
connection.close()
From Oracle document:
When Remove infected Connections Enabled=true (default value) and you close the logical connection, the server instance discards the underlying physical connection and creates a new connection to replace it. This action ensures that the pool can guarantee to the next user that they are the sole user of the pool connection. This configuration provides a simple and safe way to close a connection. However, there is a performance loss because:
The physical connection is replaced with a new database connection in the connection pool, which uses resources on both the application server and the database server.
The statement cache for the original connection is closed and a new cache is opened for the new connection. Therefore, the performance gains from using the statement cache are lost.
Note:
Oracle provides another mechanism to access a physical connection getVendorConnectionSafe. This mechanism also returns the underlying physical connection (the vendor connection) from a pooled database connection (a logical connection). However, when the connection is closed, it is returned to the pool, independent of the setting of Remove Infected Connections Enabled. For more information, see getVendorConnectionSafe.
|