Subject | Failure on PreparedStatement |
---|---|
Author | Robert DiFalco |
Post date | 2003-04-04T17:44:21Z |
I'm getting a failure on a prepared statement. It seems that even if I
am doing something wrong that it shouldn't fail in this way (i.e.
IllegalStateException).
Here's a small unit test:
public void testPreparedStatement() throws Exception
{
Connection con = ConnectionFactory.createInstance();
try
{
PreparedStatement st = con.prepareStatement( "SELECT
ClassMap.oid,classname,mapping,codebase FROM ClassMap WHERE
classname=?;" );
st.setObject( 1, Persistent.class.getName() );
ResultSet rs = st.executeQuery();
assertTrue( rs.next() );
}
catch ( Exception e )
{
e.printStackTrace();
}
finally
{
con.close();
}
}
"classname" is a BLOB SUB_TYPE 1 field.
The error I get is:
java.lang.IllegalStateException: Can't destroy managed connection with
active transaction
at
org.firebirdsql.jca.FBManagedConnection.destroy(FBManagedConnection.java
:333)
at
org.firebirdsql.jca.FBStandAloneConnectionManager.connectionErrorOccurre
d(FBStandAloneConnectionManager.java:84)
at
org.firebirdsql.jca.FBManagedConnection$2.notify(FBManagedConnection.jav
a:1121)
at
org.firebirdsql.jca.FBManagedConnection.notify(FBManagedConnection.java:
1094)
at
org.firebirdsql.jca.FBManagedConnection.checkFatal(FBManagedConnection.j
ava:726)
at
org.firebirdsql.jca.FBManagedConnection.fetch(FBManagedConnection.java:8
08)
at
org.firebirdsql.jdbc.FBConnection.fetch(FBConnection.java:1091)
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:11
3)
at
org.firebirdsql.jdbc.FBStatementFetcher.<init>(FBStatementFetcher.java:5
5)
at org.firebirdsql.jdbc.FBResultSet.<init>(FBResultSet.java:103)
at
org.firebirdsql.jdbc.FBStatement.getResultSet(FBStatement.java:550)
at
org.firebirdsql.jdbc.FBPreparedStatement.executeQuery(FBPreparedStatemen
t.java:106)
at
com.tripwire.space.core.persistence.db.DatabaseFacade.performSearch(Data
baseFacade.java:207)
at
com.tripwire.space.core.persistence.PersistenceMapping.search(Persistenc
eMapping.java:375)
at
com.tripwire.space.core.persistence.db.PersistenceMappingRegistry.ensure
Stored(PersistenceMappingRegistry.java:202)
at
com.tripwire.space.core.persistence.db.PersistenceMappingRegistry.regist
er(PersistenceMappingRegistry.java:77)
at
com.tripwire.space.core.persistence.db.DatabasePersistenceManager.regist
erMapping(DatabasePersistenceManager.java:46)
at
com.tripwire.space.core.persistence.TestPersistent.setUp(TestPersistent.
java:35)
at junit.framework.TestCase.runBare(TestCase.java:125)
at
com.tripwire.util.AbstractTestCase.doRunBare(AbstractTestCase.java:178)
at
com.tripwire.util.AbstractTestCase.runBare(AbstractTestCase.java:148)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at junit.textui.TestRunner.main(TestRunner.java:138)
at com.tripwire.util.Tester.main(Tester.java:80)
am doing something wrong that it shouldn't fail in this way (i.e.
IllegalStateException).
Here's a small unit test:
public void testPreparedStatement() throws Exception
{
Connection con = ConnectionFactory.createInstance();
try
{
PreparedStatement st = con.prepareStatement( "SELECT
ClassMap.oid,classname,mapping,codebase FROM ClassMap WHERE
classname=?;" );
st.setObject( 1, Persistent.class.getName() );
ResultSet rs = st.executeQuery();
assertTrue( rs.next() );
}
catch ( Exception e )
{
e.printStackTrace();
}
finally
{
con.close();
}
}
"classname" is a BLOB SUB_TYPE 1 field.
The error I get is:
java.lang.IllegalStateException: Can't destroy managed connection with
active transaction
at
org.firebirdsql.jca.FBManagedConnection.destroy(FBManagedConnection.java
:333)
at
org.firebirdsql.jca.FBStandAloneConnectionManager.connectionErrorOccurre
d(FBStandAloneConnectionManager.java:84)
at
org.firebirdsql.jca.FBManagedConnection$2.notify(FBManagedConnection.jav
a:1121)
at
org.firebirdsql.jca.FBManagedConnection.notify(FBManagedConnection.java:
1094)
at
org.firebirdsql.jca.FBManagedConnection.checkFatal(FBManagedConnection.j
ava:726)
at
org.firebirdsql.jca.FBManagedConnection.fetch(FBManagedConnection.java:8
08)
at
org.firebirdsql.jdbc.FBConnection.fetch(FBConnection.java:1091)
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:11
3)
at
org.firebirdsql.jdbc.FBStatementFetcher.<init>(FBStatementFetcher.java:5
5)
at org.firebirdsql.jdbc.FBResultSet.<init>(FBResultSet.java:103)
at
org.firebirdsql.jdbc.FBStatement.getResultSet(FBStatement.java:550)
at
org.firebirdsql.jdbc.FBPreparedStatement.executeQuery(FBPreparedStatemen
t.java:106)
at
com.tripwire.space.core.persistence.db.DatabaseFacade.performSearch(Data
baseFacade.java:207)
at
com.tripwire.space.core.persistence.PersistenceMapping.search(Persistenc
eMapping.java:375)
at
com.tripwire.space.core.persistence.db.PersistenceMappingRegistry.ensure
Stored(PersistenceMappingRegistry.java:202)
at
com.tripwire.space.core.persistence.db.PersistenceMappingRegistry.regist
er(PersistenceMappingRegistry.java:77)
at
com.tripwire.space.core.persistence.db.DatabasePersistenceManager.regist
erMapping(DatabasePersistenceManager.java:46)
at
com.tripwire.space.core.persistence.TestPersistent.setUp(TestPersistent.
java:35)
at junit.framework.TestCase.runBare(TestCase.java:125)
at
com.tripwire.util.AbstractTestCase.doRunBare(AbstractTestCase.java:178)
at
com.tripwire.util.AbstractTestCase.runBare(AbstractTestCase.java:148)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at junit.textui.TestRunner.main(TestRunner.java:138)
at com.tripwire.util.Tester.main(Tester.java:80)