I am getting the following exception while using org.apache.commons.dbcp.ConnectionFactory for my Swing base Java application.
Database Error: Cannot get a connection, pool exhausted
Unexpected error has occured, the request can't be processed.
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
This error indicates that you are not closing connections properly and thus, it exceeds the number of available connections from the connection pool. It is a good practice to close result set, statement and connections properly to avoid this exception.
Ujjwal B Soni <baroda, gujarat, india> <+918866008962>
"Helping hands are better than praying lips......"
Thanks for the reply, i had same problem then i checked my code where am calling one method to another class method there again getting connection from datasource and its increasing the connections which i have specified in the configuration file, then i realized to increase the connections to as many times am using that didnt solved my problem again giving same error.
Then thought creating/ getting connection from datasource in main method (stating of the program) and pass the connection object to other called methods then it solved my problem and i have tested stress test like generating extracts about 1k with out any error.
You can check your code it will be good to open connection for thread and use that connection entire that thread and close at the end.
hope this will be help full.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool exhausted