You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "nntp://news.gmane.org/gmane.group.name" <r1...@in.ibm.com> on 2003/08/29 14:53:07 UTC

PreparedStement found closed already

Hi,

We have started facing this issue randomly on RC4.
Using PB API under AppServer. Called from SLSBs.
Each session calls the PBFactory().getdefaultBroker()... uses it and called
PB.close().
intermittently we are getting an SQLException which means the
PreparedStatement was closed (stack trace below)

Any ideas when/how this can happen ?
Is there a non-caching alternative to "StatementsForClassImpl"
(just to build in the thaught... we wont face this if we do no cache
PreparedStatements)

TIA
akhil

rethrown as org.apache.ojb.broker.PersistenceBrokerSQLException:
[IBM][JDBCDriver] CLI0601E Invalid statement handle or statement is
closed.SQLSTATE=S1000
at
org.apache.ojb.broker.accesslayer.StatementsForClassImpl.getPreparedStmt(Sta
tementsForClassImpl.java:188)

at
org.apache.ojb.broker.accesslayer.StatementManager.getPreparedStatement(Stat
ementManager.java:680)

at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl
.java:266)

at org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:200)

at
org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIterator
FactoryImpl.java:95)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Pers
istenceBrokerImpl.java:2371)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Persis
tenceBrokerImpl.java:1712)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1343)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1515)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1551)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
tenceBrokerImpl.java:1540)

at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Persistenc
eBrokerImpl.java:1802)

at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele
gatingPersistenceBroker.java:286)

at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele
gatingPersistenceBroker.java:286)






---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: PreparedStement found closed already

Posted by "nntp://news.gmane.org/gmane.group.name" <r1...@in.ibm.com>.
I read some more code... My line of attack was wrong.
StatementManager.getPreparedStatement() is infact called with an SQL string
so there is no caching of PreparedStatement Objects as such... but than how
can
we get "Invalid statement handle or statement is closed" from db ?

I am assuming if the PB was closed... we'd have recieved
"java.lang.IllegalStateException" much earlier in
the stack (on a DelegatingPB.getBroker() call)...

Is it possible that the connection was closed ? without calling
PB.close()...
BTW we are using connections from app server by declaring a Data Source in
app server

-akhil

"nntp://news.gmane.org/gmane.group.name" <r1...@in.ibm.com> wrote in
message news:binici$7g5$1@sea.gmane.org...
> Hi,
>
> We have started facing this issue randomly on RC4.
> Using PB API under AppServer. Called from SLSBs.
> Each session calls the PBFactory().getdefaultBroker()... uses it and
called
> PB.close().
> intermittently we are getting an SQLException which means the
> PreparedStatement was closed (stack trace below)
>
> Any ideas when/how this can happen ?
> Is there a non-caching alternative to "StatementsForClassImpl"
> (just to build in the thaught... we wont face this if we do no cache
> PreparedStatements)
>
> TIA
> akhil
>
> rethrown as org.apache.ojb.broker.PersistenceBrokerSQLException:
> [IBM][JDBCDriver] CLI0601E Invalid statement handle or statement is
> closed.SQLSTATE=S1000
> at
>
org.apache.ojb.broker.accesslayer.StatementsForClassImpl.getPreparedStmt(Sta
> tementsForClassImpl.java:188)
>
> at
>
org.apache.ojb.broker.accesslayer.StatementManager.getPreparedStatement(Stat
> ementManager.java:680)
>
> at
>
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl
> .java:266)
>
> at
org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:200)
>
> at
>
org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIterator
> FactoryImpl.java:95)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Pers
> istenceBrokerImpl.java:2371)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Persis
> tenceBrokerImpl.java:1712)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1343)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1515)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1551)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1540)
>
> at
>
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Persistenc
> eBrokerImpl.java:1802)
>
> at
>
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele
> gatingPersistenceBroker.java:286)
>
> at
>
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele
> gatingPersistenceBroker.java:286)




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: PreparedStement found closed already

Posted by Thomas Mahler <th...@web.de>.
Hi akhil,

nntp://news.gmane.org/gmane.group.name wrote:
> Hi,
> 
> We have started facing this issue randomly on RC4.
> Using PB API under AppServer. Called from SLSBs.
> Each session calls the PBFactory().getdefaultBroker()... uses it and called
> PB.close().
> intermittently we are getting an SQLException which means the
> PreparedStatement was closed (stack trace below)
> 
> Any ideas when/how this can happen ?

I think it happens because PBFactory.defaultPersistenceBroker() serves 
the same broker instance to all SBs.
So it may happen that one SB closes the broker (and closing the 
connection thus invalidating the prepared statements).
A different SB using the same broker instance is then confronted with 
closed resources an thus throws the exceptions you see.

You shoul use PBFactory.createPersistenceBroker(PBKey key) to obtain one 
broker instance for each SB.


> Is there a non-caching alternative to "StatementsForClassImpl"
> (just to build in the thaught... we wont face this if we do no cache
> PreparedStatements)

you could implement your own class, but there is no alternative 
implementation shipping with the distro.

YOu could also use the ConnectionFactoryClass entry in OJB.properties to 
specify a ConnectionFactory that behaves differently.
Have a look at OJB.properties for more details

But as I've already mentioned, I think the problem is not related to 
problems with prepared statements or connections, but with running 
multiple SBs against one broker instance.


cheers,
Thomas

> 
> TIA
> akhil
> 
> rethrown as org.apache.ojb.broker.PersistenceBrokerSQLException:
> [IBM][JDBCDriver] CLI0601E Invalid statement handle or statement is
> closed.SQLSTATE=S1000
> at
> org.apache.ojb.broker.accesslayer.StatementsForClassImpl.getPreparedStmt(Sta
> tementsForClassImpl.java:188)
> 
> at
> org.apache.ojb.broker.accesslayer.StatementManager.getPreparedStatement(Stat
> ementManager.java:680)
> 
> at
> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImpl
> .java:266)
> 
> at org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:200)
> 
> at
> org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(RsIterator
> FactoryImpl.java:95)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Pers
> istenceBrokerImpl.java:2371)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Persis
> tenceBrokerImpl.java:1712)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1343)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1515)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1551)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis
> tenceBrokerImpl.java:1540)
> 
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Persistenc
> eBrokerImpl.java:1802)
> 
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele
> gatingPersistenceBroker.java:286)
> 
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Dele
> gatingPersistenceBroker.java:286)
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org