You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ashoknan <as...@chase.com> on 2009/05/06 23:43:47 UTC

Tomcat DBCP: Getting java.sql.SQLException: Closed Statement

We are getting below exception in production randomly..Using Spring(2.5) JDBC
for all our DB related functionality.We don't handle any DB resources
directly.everything thru Spring JDBC template. This app was running fine in
Weblogic but after migrating to Tomcat 6+ DBCP we are seeing the below
exception. 

We also looked our code base for any threading or concurrency issues..we
were not able spot any issues. 

I have observed one more thing..why checkOpen in DelegatingPreparedStatement
didn't catch this but OracleStatement thinks the statement is closed.

If anbody else faced this issue before please share your solutions. 


Caused by: org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO
AUDIT_TRAIL ( DEAL_ID , AUDIT_TRAIL_ID ) VALUES ( ?,? ) ]; SQL state [null];
error code [17009]; Closed Statement; nested exception is
java.sql.SQLException: Closed Statement 
        at
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:124) 
        at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322) 
        at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:607) 
        at
org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:792) 
        at
org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:815) 
        at
org.springframework.jdbc.object.SqlUpdate.update(SqlUpdate.java:168) 
        at
com.dao.DealXAuditTrailDaoBase.insertDealXAuditTrailVoBase(Unknown Source) 
        at com.deal.DealTO.insertAuditTrail(DealTO.java:183) 
        at com.deal.DealTO.processAuditTrail(DealTO.java:168) 
        at com.deal.DealTO.update(DealTO.java:110) 
        at com.deal.DealTO$$FastClassByCGLIB$$fba55fe6.invoke(<generated>) 
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) 
        at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700) 
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) 
        at
com.businessrules.SpexBusinessRuleValidator.invoke(SpexBusinessRuleValidator.java:64) 
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) 
        at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) 
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) 
        at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635) 
        at com.deal.DealTO$$EnhancerByCGLIB$$54d9c9a4.update(<generated>) 
        at
com.entity.EntityGeneralInfoController.copyFieldsToDeal(EntityGeneralInfoController.java:1158) 
        at
com.entity.EntityGeneralInfoController.doSave(EntityGeneralInfoController.java:429) 
        ... 30 more 
Caused by: java.sql.SQLException: Closed Statement 
        at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125) 
        at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162) 
        at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227) 
        at
oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:3249) 
        at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2867) 
        at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2957) 
        at
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102) 
        at
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102) 
        at
org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:798) 
        at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:591) 




        <Resource name="oracleDS" auth="Container" 
                                type="javax.sql.DataSource" 
                                driverClassName="oracle.jdbc.OracleDriver" 
                                url="jdbc:oracle:thin:@xxxxx:1521:xxxxx" 
                                username="xxxx" password="xxxx" 
                                initialSize="2" maxActive="30" maxIdle="30"
maxWait="3000" minIdle="0" 
                                testOnBorrow="true" testOnReturn="false"
testWhileIdle="false" 
                                poolPreparedStatements="true"
maxOpenPreparedStatements="10" 
                                removedAbandoned="true"
removeAbandonedTimeout="60" 
                                logAbandoned="true" validationQuery="select
count(*) from dual"/> 

-- 
View this message in context: http://www.nabble.com/Tomcat-DBCP%3A-Getting-java.sql.SQLException%3A-Closed-Statement-tp23416137p23416137.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat DBCP: Getting java.sql.SQLException: Closed Statement

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ashoknan,

On 5/6/2009 5:43 PM, ashoknan wrote:
> This app was running fine in Weblogic but after migrating to Tomcat
> 6+ DBCP we are seeing the below exception.

Which version of TC 6 are you using? Are you using the stock DBCP or
Filip's new-fangled DBCP?

> We also looked our code base for any threading or concurrency issues..we
> were not able spot any issues. 

Famous last words.

> I have observed one more thing..why checkOpen in DelegatingPreparedStatement
> didn't catch this but OracleStatement thinks the statement is closed.

What makes you say that DelegatingPreparedStatement.checkOpen is being
called and seeing an incorrect state?

I suspect you (or the Spring folks?) are unwrapping the pooled statement
at some point to expose its Oracle-ness, and then you are (incorrectly)
closing the underlying statement instead of closing the wrapping
(pooled) statement as you should be.

> org.springframework.jdbc.object.SqlUpdate.update(SqlUpdate.java:168) 
>         at
> com.dao.DealXAuditTrailDaoBase.insertDealXAuditTrailVoBase(Unknown Source) 

This code (yours?) is calling SqlUpdate.update. What does your code look
like around here? Are you using any transactions?

>         at com.deal.DealTO.insertAuditTrail(DealTO.java:183) 
>         at com.deal.DealTO.processAuditTrail(DealTO.java:168) 
>         at com.deal.DealTO.update(DealTO.java:110) 

The code around here might be useful to see, too.

> validationQuery="select count(*) from dual"/> 

That's a weird one.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkoCRHkACgkQ9CaO5/Lv0PD01gCdH7IHL1q8iXbTmRp9HVyciRNi
wJQAnjvN+vEcyoW7TWOGnD0G04506cCO
=aFGJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org