Database Connection Parameters Derived from the JNDI Connection Pool

I have a data source on websphere server and I wanted to use this data source through my application clients.

After retrieving the database connection from the JNDI data source, I change the connection fix parameter to false. After that, I will use this connection, and I will close the connection after completing the task.

My doubt is what happens if I forget to change the connection fix setting before closing (I mean returning the connection to the pool). If any other client accesses this data source and receives the same connection, the commit settings are still saved or the server will reset these connection settings.

Regards, Sunny.

+4
source share
1 answer

Usually, connections in the pool are wrapped up in AS-specific implementation, which ensures that the client is too intrusive. When certain methods in a connection are called, it is considered dirty and cannot be returned to the pool, but closed and recreated instead, or reset to its original state, if possible. Frequently asked questions about how to deal with these situations, for example. Delete infected connections in Weblogic.

The effect of these self-cleaning can also depend on the driver. Therefore, I suggest you conduct a simple test with a 1-connection pool. Establish a connection with autocommit = false, do not close it, exit and try to use it with another client with a test that checks the actual state of the autocommit property.

Another thing to consider is that Connection.close () is that the AS shell does not close the connection, but puts it in the pool. Therefore, if the client disconnects before calling the close () function (and before setting the autorun back), the connection may not be available to other clients in the pool, creating a connection leak.

+3
source

Source: https://habr.com/ru/post/1345716/


All Articles