wood burning stoves 2.0*
The moose likes JDBC and the fly likes cannot get connection, pool exhausted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "cannot get connection, pool exhausted" Watch "cannot get connection, pool exhausted" New topic
Author

cannot get connection, pool exhausted

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
org.apache.tomcat.dbcp.dbcp.SQLNestedException: cannot get connection, pool exhausted.

i have configured connection pooling in tomcat in the context.xml file.
i have created a class with static method which will return the connection object from the datasource.
Iam using this connection object every time for database transactions.

At some time iam geeting this error..
org.apache.tomcat.dbcp.dbcp.SQLNestedException: cannot get connection, pool exhausted.

here are the configuration settings.....
<Resource
name="jdbc/pool"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
username="scott"
password="tiger"
driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbcdbc:pool"
maxWait="1000"
removeAbandoned="true"
maxActive="130"
maxIdle="10"
removeAbandonedTimeout="300"
logAbandoned="true"
/>

Database used : Oracle 9i
driver: jdbc odbc driver (type 1)
Server: tomcat 5.5
can any one tell me how to solve this problem...if i increase the maxinActive="" attribute value to 140 iam getting the following error..

java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00020: maximum number of processes (150) exceeded...

how to over come this problem....?

here is the stack trace for the first problem pool exhausted...
-----------------------------------------------------------------------
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool ex
hausted
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDa
taSource.java:103)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSo
urce.java:540)
at rollno.Connect.getConnection(Connect.java:30)
at org.apache.jsp.admninterface_jsp._jspService(admninterface_jsp.java:7
8)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:328)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
15)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:691)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica
tionDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:301)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.j
ava:691)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.jav
a:661)
at org.apache.jsp.loginform12_jsp._jspService(loginform12_jsp.java:193)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:328)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
15)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:685)
at java.lang.Thread.run(Unknown Source)
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
at org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.borrowObject(Gener
icObjectPool.java:756)
at org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool.borrowObject(Abandone
dObjectPool.java:74)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDa
taSource.java:95)
------------------------------------------------------------

thanks in advance


Abhishek
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
If you fail to close a Connection after usage, then then it won't be returned to the pool. This can cause pool exhaustion.

Also, check that the setting for the maximum number of connections in the pool is adequate.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
thanks for the reply

can you tell me how to check whether the maximum number of connections in the pool is adequate or not?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot get connection, pool exhausted
 
Similar Threads
Liferay-JBoss-Tomcat5.2.3 getting java.lang.ClassCastException in a portlet
JetSpeed2 - alot of exceptions
java.sql.SQLException: Io exception: Software caused connection abort: recv fail
java.sql.SQLException: Io exception: Software caused connection abort: recv fail
query on Hibernate