Reputation: 415
I have a strange problem with dbUnit. I use dbUnit 2.4.4, java 1.6, Spring (as db connection pool), Oracle 9 for my project with about 50 unit tests. For some of them (when I run whole set of tests) I get such exception:
Closed Statement
[junit] junit.framework.AssertionFailedError: Closed Statement
[junit] at com.myproj.DataAccess.Internal.BaseDAOTest.importToDb(Unknown Source)
[junit] at com.myproj.DataAccess.Internal.MyDAOTest.testGetBuyClientOrders(Unknown Source)
[junit] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[junit] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[junit] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
importToDb method loads test data from XML file to database via dbUnit's DatabaseOperation.REFRESH.execute method and it is used in ALL tests. If I run these tests with problems separately, there is no problems for them. Do you have any ideas? Thanks!
Upvotes: 0
Views: 3634
Reputation: 10001
When this happened to me, we had explicitly configured our connection cache to snipe long-lasting connections using two properties:
AbandonedConnectionTimeout
InactivityTimeout
See Oracle's docs here regarding timeout properties
It turned out that the query+processing time was just jumping the cusp of the two properties combined (AbandonedConnectionTimeout + InactivityTimeout < query time + resultset processing time).
To fix the issue, you can either raise your timeout limits or you can remove the timeout by setting them to 0 (the default)
Upvotes: 1
Reputation: 39733
I guess some of your tests close the database connection when they clean up. The next test tries to use this connection again for the import and fails.
Upvotes: 1