You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by mean_bcp <go...@versatilets.com> on 2016/10/03 17:42:20 UTC

JDBC connection pool: Closed connections

Using the default connection pooling, with test on borrow set to true. Why
would a connection sometimes be closed right after I get it from the data
source? Any suggestions to optimize my config?

resources.xml:

<resources>
	<Resource id="dolleeDb" type="DataSource">
		JdbcDriver oracle.jdbc.OracleDriver
		JtaManaged false
		UserName dollapp
		Password dollapp
		ConnectionProperties oracle.jdbc.ReadTimeout=5000;
		ValidationQuery select 1 from dual
		TestOnBorrow true
		InitialSize 20
	</Resource>
</resources>

java:

conn = ds.getConnection();

(datasource initialized here:)

Context initCtx = new InitialContext();
String dsName = props.getProperty("db.datasource")
String s = "openejb:Resource/" + dsName;
DataSource ds = (javax.sql.DataSource) initCtx.lookup(s);

Stacktrace:

java.sql.SQLRecoverableException: Closed Connection
        at
oracle.jdbc.driver.PhysicalConnection.getMetaData(PhysicalConnection.java:5216)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at
org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
        at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
        at
org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80)
        at com.sun.proxy.$Proxy65.getMetaData(Unknown Source)
        at
com.comcast.dollee.common.GenericDAO.initConnection(GenericDAO.java:76)
        ...



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JDBC-connection-pool-Closed-connections-tp4680278.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JDBC connection pool: Closed connections

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Check number of used connection vs your max at that moment and try to
reproduce in a sample if it is not a limit set too low.

I know we improve a bit the jta management without dbcp on master but doubt
it is that, looks more like an unexpected underlying access with that stack.

Le 3 oct. 2016 19:48, "mean_bcp" <go...@versatilets.com> a écrit :

Using the default connection pooling, with test on borrow set to true. Why
would a connection sometimes be closed right after I get it from the data
source? Any suggestions to optimize my config?

resources.xml:

<resources>
        <Resource id="dolleeDb" type="DataSource">
                JdbcDriver oracle.jdbc.OracleDriver
                JtaManaged false
                UserName dollapp
                Password dollapp
                ConnectionProperties oracle.jdbc.ReadTimeout=5000;
                ValidationQuery select 1 from dual
                TestOnBorrow true
                InitialSize 20
        </Resource>
</resources>

java:

conn = ds.getConnection();

(datasource initialized here:)

Context initCtx = new InitialContext();
String dsName = props.getProperty("db.datasource")
String s = "openejb:Resource/" + dsName;
DataSource ds = (javax.sql.DataSource) initCtx.lookup(s);

Stacktrace:

java.sql.SQLRecoverableException: Closed Connection
        at
oracle.jdbc.driver.PhysicalConnection.getMetaData(
PhysicalConnection.java:5216)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at
org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
        at
org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109)
        at
org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(
DisposableConnectionFacade.java:80)
        at com.sun.proxy.$Proxy65.getMetaData(Unknown Source)
        at
com.comcast.dollee.common.GenericDAO.initConnection(GenericDAO.java:76)
        ...



--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/JDBC-connection-pool-Closed-connections-tp4680278.html
Sent from the TomEE Users mailing list archive at Nabble.com.