Skip to Main Content
  • Questions
  • Oracle 11g Database - Need to reduce "Leaked Connection Count" Issue

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Ng Cho Wai.

Asked: February 11, 2021 - 3:47 am UTC

Last updated: February 17, 2021 - 7:02 am UTC

Version: JDeveloper 11.1.1.5.0

Viewed 1000+ times

You Asked

Dear Tom,

I am using Oracle 11g Database, a Production Java Web Application is using, which is written in Jdeveloper 11.1.1.5.0.

When the system is performing simple UI record updating, there is no. of Leaked Connection Count generated after saving.

Briefing:

After reviewing the log, there is error show as below:

<XX_XXX> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <fb12d27fe30e4542:6dc3ab72:17780cd0503:-8000-0000000000042df2> <1612946549483> <BEA-001153> <Forcibly releasing inactive connection "weblogic.jdbc.wrapper.PoolConnection_oracle_jdbc_driver_T4CConnection@9b65" back into the connection pool "xxx_nonXA", currently reserved by: java.lang.Exception

:

at xxxx.xx.xxx.xxx.xxx.bean.RoleCommonBean.commitSaveUpdate(RoleCommonBean.java:256)

=> For ((RoleCommonBean.java:256) , it is showing "operationBinding.execute()

=> In Oracle Weblogic Server, the parameter "Inactive Connection Timeout" has set to Zero and

the "Remove Infected Connections Enabled" has also enabled.

Question raise:

Q1) Is there any "Exception handling" or else need to improve at Java program in order to reduce this error? any example?

Q2) Do we need to adjust the setting of above parameter mentioned? What is the use of these 2 parameters?

Q3) What is connection pooling? Would you mind giving an example(s) that show thorough understanding of the JDBC application connections to the oracle database?

Q4) Any directions provided to me in order to reduce "Leaked Connection Count"?

Thank you for your kind attention

Best Regards

David

and Connor said...

This generally is an app coding issue - you run a piece of code and it takes a path that ends up never reaching the appropriate 'close' for the statement and/connection, and thus you have a leaked connection.

This used to end up with errors along the lines of "no more connections available" but because the problem is so common :-( the settings to hunt down inactive connections you've mentioned came into being, and hence we start recording "leaked" connections, ie, weblogic closed it because the app did not.

Details on correctly closing statements etc here

https://docs.oracle.com/cd/E13222_01/wls/docs103/jdbc/troubleshooting.html#wp1024080

Also a common culprit is locally opening an existing connection ,eg

public ... MyDbRoutine(Connection c, .....)
{
   c = [initiate a connection]
}


and thus you've opened another instance of connection that was already passed to you. You'll end up opening two and closing one

There's a good intro to connection pooling here

https://docs.oracle.com/en/database/oracle/oracle-database/18/tdpjd/using-java-with-oracle-database.html#GUID-8C73108B-E0F3-4CD5-A813-909B339339BB

and there are code samples on our github page, eg

https://github.com/oracle/oracle-db-examples/blob/master/java/jdbc/BasicSamples/UCPSample.java

Also check out MOS note 1502054.1 for using JDBC dumps to find problem code.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks to Professional

Ng Cho Wai, David, February 16, 2021 - 3:04 pm UTC

Thanks a lot
Connor McDonald
February 17, 2021 - 7:02 am UTC

hope this helped

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here