You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nathan Christiansen <Na...@tni.com> on 2003/09/17 22:20:00 UTC
RE: MySQL DBCP pool exausted error message [SOLVED]
Sorry. I had a bug in my code.
I had one database call where I was checking parameters and returning without calling Connection.close();
-- Nathan Christiansen
Tahitian Noni International
http://www.tahitiannoni.com
-----Original Message-----
From: Nathan Christiansen
Sent: Wednesday, September 17, 2003 11:20 AM
To: tomcat-user@jakarta.apache.org
Subject: MySQL DBCP pool exausted error message
When I stress test my web app using JMeter, I am suddenly getting a "DBCP could not obtain an idle db connection, pool exhausted" SQLException thrown.
When I test with 25 simulated users every one of my 25 threads gets the exception after the first 25 requests.
What am I doing wrong?
My setup:
RH Linux 7.1
Java 1.4.1_01
Tomcat 4.1.24
DBCP 1.0
MySQL 3.23.56
My pertinent DBCP configuration:
removeAbandoned = true
maxActive = 25
maxIdle = 10
maxWait = 10000
url ends with ?autoReconnect=true
I double checked that all of my database connections in my code follow the pattern of:
Connection conDBConnection = getConnection();
PreparedStatement psDBStatement = null;
ResultSet rsDBResult = null;
try
{
psDBStatement = conDBConnection.prepareStatement("select query from views where viewid = ?");
psDBStatement.setInt(1, nViewID);
rsDBResult = psDBStatement.executeQuery();
if (rsDBResult.next())
{
strReturnValue = rsDBResult.getString(1);
}
}
catch (SQLException sqle)
{
sqle.printStackTrace();
strReturnValue = null;
}
finally
{
try
{
if (rsDBResult != null) rsDBResult.close();
if (psDBStatement != null) psDBStatement.close();
if (conDBConnection != null) conDBConnection.close();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
}
-- Nathan Christiansen
Tahitian Noni International
http://www.tahitiannoni.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: MySQL DBCP pool exausted error message [SOLVED]
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Guess you won't be needing my reply then, but looking at your code, it
seems that your finally block could be improved slightly :)
In the rare situation where statement.close() throws an exception, your
connection won't be closed.
Adam
On 09/17/2003 10:20 PM Nathan Christiansen wrote:
> Sorry. I had a bug in my code.
>
> I had one database call where I was checking parameters and returning without calling Connection.close();
>
> -- Nathan Christiansen
> Tahitian Noni International
> http://www.tahitiannoni.com
>
>
> -----Original Message-----
> From: Nathan Christiansen
> Sent: Wednesday, September 17, 2003 11:20 AM
> To: tomcat-user@jakarta.apache.org
> Subject: MySQL DBCP pool exausted error message
>
>
> When I stress test my web app using JMeter, I am suddenly getting a "DBCP could not obtain an idle db connection, pool exhausted" SQLException thrown.
>
> When I test with 25 simulated users every one of my 25 threads gets the exception after the first 25 requests.
>
> What am I doing wrong?
>
> My setup:
>
> RH Linux 7.1
> Java 1.4.1_01
> Tomcat 4.1.24
> DBCP 1.0
>
> MySQL 3.23.56
>
>
> My pertinent DBCP configuration:
>
> removeAbandoned = true
> maxActive = 25
> maxIdle = 10
> maxWait = 10000
> url ends with ?autoReconnect=true
>
> I double checked that all of my database connections in my code follow the pattern of:
>
> Connection conDBConnection = getConnection();
> PreparedStatement psDBStatement = null;
> ResultSet rsDBResult = null;
>
> try
> {
> psDBStatement = conDBConnection.prepareStatement("select query from views where viewid = ?");
> psDBStatement.setInt(1, nViewID);
> rsDBResult = psDBStatement.executeQuery();
>
> if (rsDBResult.next())
> {
> strReturnValue = rsDBResult.getString(1);
> }
> }
> catch (SQLException sqle)
> {
> sqle.printStackTrace();
> strReturnValue = null;
> }
> finally
> {
> try
> {
> if (rsDBResult != null) rsDBResult.close();
> if (psDBStatement != null) psDBStatement.close();
> if (conDBConnection != null) conDBConnection.close();
> }
> catch (SQLException sqle)
> {
> sqle.printStackTrace();
> }
> }
>
>
>
>
> -- Nathan Christiansen
> Tahitian Noni International
> http://www.tahitiannoni.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: MySQL DBCP pool exausted error message [SOLVED]
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Guess you won't be needing my reply then, but looking at your code, it
seems that your finally block could be improved slightly :)
In the rare situation where statement.close() throws an exception, your
connection won't be closed.
Adam
On 09/17/2003 10:20 PM Nathan Christiansen wrote:
> Sorry. I had a bug in my code.
>
> I had one database call where I was checking parameters and returning without calling Connection.close();
>
> -- Nathan Christiansen
> Tahitian Noni International
> http://www.tahitiannoni.com
>
>
> -----Original Message-----
> From: Nathan Christiansen
> Sent: Wednesday, September 17, 2003 11:20 AM
> To: tomcat-user@jakarta.apache.org
> Subject: MySQL DBCP pool exausted error message
>
>
> When I stress test my web app using JMeter, I am suddenly getting a "DBCP could not obtain an idle db connection, pool exhausted" SQLException thrown.
>
> When I test with 25 simulated users every one of my 25 threads gets the exception after the first 25 requests.
>
> What am I doing wrong?
>
> My setup:
>
> RH Linux 7.1
> Java 1.4.1_01
> Tomcat 4.1.24
> DBCP 1.0
>
> MySQL 3.23.56
>
>
> My pertinent DBCP configuration:
>
> removeAbandoned = true
> maxActive = 25
> maxIdle = 10
> maxWait = 10000
> url ends with ?autoReconnect=true
>
> I double checked that all of my database connections in my code follow the pattern of:
>
> Connection conDBConnection = getConnection();
> PreparedStatement psDBStatement = null;
> ResultSet rsDBResult = null;
>
> try
> {
> psDBStatement = conDBConnection.prepareStatement("select query from views where viewid = ?");
> psDBStatement.setInt(1, nViewID);
> rsDBResult = psDBStatement.executeQuery();
>
> if (rsDBResult.next())
> {
> strReturnValue = rsDBResult.getString(1);
> }
> }
> catch (SQLException sqle)
> {
> sqle.printStackTrace();
> strReturnValue = null;
> }
> finally
> {
> try
> {
> if (rsDBResult != null) rsDBResult.close();
> if (psDBStatement != null) psDBStatement.close();
> if (conDBConnection != null) conDBConnection.close();
> }
> catch (SQLException sqle)
> {
> sqle.printStackTrace();
> }
> }
>
>
>
>
> -- Nathan Christiansen
> Tahitian Noni International
> http://www.tahitiannoni.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9