Skip to main content

JDBC Connection Leak in ADF app on a WebLogic Server

It's an old topic but worthy to post as it happens frequent enough in codes that I observed.

The bottom line of the issue that I am going to describe here is a coding issue, to it applies to WebLogic 11g as well as 12c.

An ADF app deployed on a remote WebLogic Server went to an error page frequently. Checking the log, I found it's complaining on "JBO-26061: Error while opening JDBC connection". The next thing I did is checking the data source of the ADF App configured on the WebLogic Server console.

On the Data Source -> Monitoring -> Statistics, the "Active Connection Average Count", "Active Connections Current Count" and "Active Connection High Count" all showed "15", which is the default max capacity of a connection pool. This shows all the connections are taken and no more connection available. I go to Monitoring -> Testing, select on the affected server and click on "Test Data Source", such error will shown "weblogic.common.resourcepool.ResourceLimitException: No resources currently available".

At this moment, it's pretty clear that the ADF App takes all the connections and not releases them properly. In another word, there could be a JDBC connection leak. There is a column "Leaked Connection Count" in the same table as "Active Connections Current Count". It is showing "0" but don't let it fool you as it's no magic for the console to tell you there is a leak right now without doing some tweaking.

Now go to the data source Configuration -> Connection Pool, expand "Advanced", there will be a setting for "Inactive Connection Timeout" with default "0". As soon as I set it for "15", I started to see the "Leaked Connection Count" start to grow. This "15" means after "15 seconds" of the server detecting an idle JDBC connection, it forcefully release the connection back to the pool and then mark it as a leaked connection.

The culprit of the issue still resides in the application. Do a search for "connection" or "statement" in the application (model layer) and see if there is any usage of manual creation of any connection, statement or result set object without properly closing them.

A document reference on properly closing JDBC objects : https://docs.oracle.com/cd/E13222_01/wls/docs103/jdbc/troubleshooting.html#wp1024080

Comments