Bug 64107 - PreparedStatements correctly closed are not returning to pool. Leads to PreparedStatement Pool exhaustion.
Summary: PreparedStatements correctly closed are not returning to pool. Leads to Prepa...
Status: NEW
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-30 17:33 UTC by tarun.kalra
Modified: 2020-01-30 17:33 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tarun.kalra 2020-01-30 17:33:24 UTC
In our code there is a sql statement that is fired multiple times with different input values. The datasource is configured to use pooling of prepared statements. The pool runs out of available preparedstatements with even single user. Below is the error that is thrown.

Cause:
java.util.NoSuchElementException: Pool exhausted
java.sql.SQLException: MaxOpenPreparedStatements limit reached


The statements are being closed correctly and as per documentation should return to the pool available for next sql execution.

Below is the jdbc resource definition. 

<Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" type="javax.sql.DataSource"
name="jdbc/SomeDataSourceName" password="<password>" username="<username>"
url="<dburl>"
maxTotal="10" initialSize="5" maxIdle="8" minIdle="0" maxWaitMillis="5000" poolPreparedStatements="true"
maxOpenPreparedStatements="150" testOnBorrow="false" testWhileIdle="true" validationQuery="select 1"
timeBetweenEvictionRunsMillis="900000" removeAbandonedTimeout="180" removeAbandonedOnBorrow="true"
removeAbandonedOnMaintenance="true" logAbandoned="false" minEvictableIdleTimeMillis="1800000" />