Please DO NOT cross-post questions to both the users list and the dev list.

Questions like this belong on the users list.


On 15/02/2023 06:32, Promit Banik wrote:
Hello everyone,

Recently we have done an environment setup upgradation/migration as
mentioned below for our application:
JDK 1.7 ---> JDK 1.8
Tomcat 7.0.47 ---> Tomcat 9.0.60 (Also using Apache HTTP Server along with
Apache Tomcat for new setup)
ojdbc7.jar ---> ojdbc8.jar
Oracle 12c (12.1.0.2.0) ---> Oracle 19c (19.14.0.0)

We have been facing a JDBC autocommit issue since then in this new
environment setup:

Issue: For the first time AutoCommit is true by default. We update the
value of autocommit to false and manually commit the transaction. After
that, we also close the connection. Now if we try to create another
connection object with "DataSource.getConnection()" within 10 seconds (in
debug mode), the previous connection object is getting assigned with
autocommit value to false. But, we expect a new connection object to be
assigned with autocommit value set to true.

During debugging, we found that in the "GenericObjectPool" class, inside
the method "borrowObject", the line "p = idleObjects.pollFirst();" assigns
(i) if within 10 seconds=> the value of p is the previous connection
object; or,
(ii) if after 10 seconds=> the value of p is null and thus one new
connection object is created for p with autocommit value to true

You need to set an explicit default for autoCommit in the DBCP configuration. That will ensure each connection obtained from the pool, whether new or reused, will have the expected value.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to