Dbunit 2.2 Closed connection SQLException

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dbunit 2.2 Closed connection SQLException

murali mohan
Hello,

I am using DBunit for the first time. I am getting an exception while running a sample test case with dbunit-2.2. The same test works fine for dbunit-2.1.

DBUnit - 2.1, Oracle - 9, Java - 1.5

The test case:
    public class UserTest  extends DatabaseTestCase{

        protected IDataSet getDataSet() throws Exception {
            return new XmlDataSet(new FileReader("src/test/resources/dataset.xml"));
        }
       

        protected IDatabaseConnection getConnection() throws Exception{
            Class driverClass =
                 Class.forName("oracle.jdbc.driver.OracleDriver");
           
            Connection jdbcConnection =     DriverManager.getConnection(
                  "jdbc:oracle:thin:@localhost:1521:engels", "murali", "murali");
            String schemaname = "murali";
               return new DatabaseConnection(jdbcConnection, schemaname.toUpperCase());
        }
       
    // the first test starts here
        public void testUser() throws Exception {
            System.out.println("Hello world test");
        }


Exception Trace

java.sql.SQLException: Closed Connection
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:208)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:840)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:759)
    at org.dbunit.database.statement.AbstractPreparedBatchStatement.<init>(AbstractPreparedBatchStatement.java:40)
    at org.dbunit.database.statement.SimplePreparedStatement.<init>(SimplePreparedStatement.java:44)
    at org.dbunit.database.statement.PreparedStatementFactory.createPreparedBatchStatement(PreparedStatementFactory.java:58)
    at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:162)
    at org.dbunit.AbstractDatabaseTester.executeOperation (AbstractDatabaseTester.java:132)
    at org.dbunit.AbstractDatabaseTester.onTearDown(AbstractDatabaseTester.java:65)
    at org.dbunit.DatabaseTestCase.tearDown(DatabaseTestCase.java:130)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run (JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:196)


Please help.

M.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Dbunit 2.2 Closed connection SQLException

murali mohan
Hello,

This is still not solved.

I tried overriding the closeConnection method as suggested in the DatabaseTestCase API docs. But the exception remains. I can see that the connection is getting closed at AbstractDatabaseTester which may be the reason why i am getting this exception. What is the proper method to override this connection closing behaviour?

M.

On Jan 4, 2008 12:21 PM, murali mohan <[hidden email]> wrote:
Hello,

I am using DBunit for the first time. I am getting an exception while running a sample test case with dbunit-2.2. The same test works fine for dbunit-2.1.

DBUnit - 2.1, Oracle - 9, Java - 1.5

The test case:
    public class UserTest  extends DatabaseTestCase{

        protected IDataSet getDataSet() throws Exception {
            return new XmlDataSet(new FileReader("src/test/resources/dataset.xml"));
        }
       

        protected IDatabaseConnection getConnection() throws Exception{
            Class driverClass =
                 Class.forName("oracle.jdbc.driver.OracleDriver");
           
            Connection jdbcConnection =     DriverManager.getConnection(
                  "jdbc:oracle:thin:@localhost:1521:engels", "murali", "murali");
            String schemaname = "murali";
               return new DatabaseConnection(jdbcConnection, schemaname.toUpperCase());
        }
       
    // the first test starts here
        public void testUser() throws Exception {
            System.out.println("Hello world test");
        }


Exception Trace

java.sql.SQLException: Closed Connection
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:208)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:840)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:759)
    at org.dbunit.database.statement.AbstractPreparedBatchStatement.<init>(AbstractPreparedBatchStatement.java:40)
    at org.dbunit.database.statement.SimplePreparedStatement.<init>(SimplePreparedStatement.java:44)
    at org.dbunit.database.statement.PreparedStatementFactory.createPreparedBatchStatement(PreparedStatementFactory.java:58)
    at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:162)
    at org.dbunit.AbstractDatabaseTester.executeOperation (AbstractDatabaseTester.java:132)
    at org.dbunit.AbstractDatabaseTester.onTearDown(AbstractDatabaseTester.java:65)
    at org.dbunit.DatabaseTestCase.tearDown(DatabaseTestCase.java:130)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run (JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java:196)


Please help.

M.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user