Exceeding the maximum latency in a Java web application using Oracle DB

I have a Java web application connecting to an Oracle database running on another machine (not sure if this is relevant or not). I use DBCP to pool pools. The web application runs in JBoss 4.2.2, and we define our data source as a bean in Spring.

We use Hibernate for ORM.

Sometimes we get errors: "ORA-02396: The maximum idle time has been exceeded, please reconnect."

I tried adding properties to our DBCP BasicDataSource called "removeAbandoned" (true) and "removeAbandondedTimeout" (120) to no avail.

Any help would be greatly appreciated. If I need to provide additional information, please let me know - I am not so knowledgeable about the internal operation of the connection pool, etc.

+3
source share
3 answers

Try setting the property testWhileIdleto truewhen setting up your data source. You will also need a test query - for Oracle, something like that is enough select 1 from dual.

This will cause dbcp to push any unoccupied connections so that they are fresh.

, , , . , minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis maxIdle/minIdle.

+7

spring .

c3p0, testWhileIdle spring:

<prop key="hibernate.dbcp.testWhileIdle">true</prop>

<prop key="hibernate.dbcp.validationQuery">
select 1 from dual
</prop>
0

I would switch to the Oracle Universal Connection Pool library. It is optimized for Oracle JDBC Connections, but will also work with any JDBC driver if you ever switch. It is also compatible with JDBC 4.0 and actually works. C3P0, Proxool, DBCP all froze. It will test your connection by pinging for Oracle, not a query, which is much faster.

Oracle UCP

0
source

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


All Articles