Reputation: 67
Sometimes i get
> java.sql.SQLException: Could not get a valid Connectionexception
when my web app try to connect database. I am using JDBC, Preparement Statement and as a server Apache Tomcat 6.This error only goes away when i restart Apache server. Can anyone tell me what is the reason of this exception and how can i fix it ?. I am sure credentals are correct.
Here is the complete log :
> Couldn't connect to database with following credentials : jdbc:oracle:thin:@129.1.2.163:1522:TAPPROD/CRANE_TP
java.sql.SQLException: Could not get a valid Connection...
at UtilityPack.DBPack.ConnCacheBean.getPoolConnection(ConnCacheBean.java:203)
at UtilityPack.DBPack.ConnCacheBean.getConnection(ConnCacheBean.java:217)
at UtilityPack.DBPack.SessionStruct.getNewConnection(SessionStruct.java:881)
at CraneInfra.JSPReceiver.beforePreprocessPage(JSPReceiver.java:147)
at JSPManager.HAPJSPReceiver.preProcessPage(HAPJSPReceiver.java:424)
at org.apache.jsp.CraneDesktop.Login_jsp._jspService(Login_jsp.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at com.googlecode.psiprobe.Tomcat60AgentValve.invoke(Tomcat60AgentValve.java:30)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Upvotes: 0
Views: 514
Reputation: 1338
Check the connection URL. You can use the fully qualified URL as shown below. jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))
You can also test using the EasyConnect URL as shown below. =jdbc:oracle:thin:HR/hr@//localhost:1521/myservicename
We recommend using fully qualified URL and not easy connect URL.
Upvotes: 1
Reputation: 141
Either you have configured too Few connection in your connection pool or you are not releasing / closing the Connection.
Try closing the connection after execution of your prepared statement
<<yourConnection>>.close();
Upvotes: 0
Reputation: 294
Problem could very well be with how your connection pool is configured. Could be to few connections, connections not being released, or zombie connections. (I think that is what they are called.)
Check out Tomcat's doc on how to specify such settings. It is a topic that really is custom each time so more than likely trial-by-error will be your best bet.
Upvotes: 0