org.h2.jdbc.JdbcSQLException: The object is already closed [90007-113]

While running junit using in memory database H2 I was hitting this error. I was testing my spring DAO classes that are using JDBCTemplate. In a single Junit testing, to test various scenario  I was calling a single DAO method with different parameters . It start giving the error "The object is already closed" as it finishes testing the DAO method with first parameter.

Then I investigated in JDBCTemplate and found that it closes connection after every execution of query using Finally statement.

finally {
            JdbcUtils.closeStatement(stmt);
            DataSourceUtils.releaseConnection(con, getDataSource());
        }

To solve this issue I override the JDBCTemplate and created my own JDBCTemplate in which I have removed the Finally statement.

HSQLDB : java.sql.SQLException: User not found: SA

While running HSQLDB in standalone mode you may face the error

  java.sql.SQLException: User not found: SA

This is because while creating the DB using script file you are not creating the user

CREATE USER SA PASSWORD ""

The above command you have to include in your db.script file db is your database name) this will creates a user by name SA with blank password.