3

I am getting below exception in one of Spring Batch Unit run while getting connection from pool. I have diagnosed and also tried by changing the properties of pool but still same error in only one specific test. All other tests are running fine.

Connection pool properties:

dataSource.maxPoolSize=5
dataSource.maxConnectionReuseTime.sec=45
dataSource.inactiveConnectionTimeout.sec=45
dataSource.minPoolSize=0
dataSource.initialPoolSize=1

Get connection code:

private IDatabaseConnection getConnection( Connection con ) throws Exception {
    // get connection

    // oracle schema name is the user name
    String schemaOwner = new JdbcTemplate( dataSource ).queryForObject( "select sys_context( 'userenv', 'current_schema' ) from dual", String.class );
    IDatabaseConnection connection = new DatabaseConnection(con, schemaOwner.toUpperCase(Locale.ENGLISH));
    DatabaseConfig config = connection.getConfig();
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new Oracle10DataTypeFactory());
    config.setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE, new String[] {"TABLE", "VIEW","ALIAS", "SYNONYM"});
    return connection;
}

protected void setUp() throws Exception {
    Connection con = DataSourceUtils.getConnection( dataSource );
    IDatabaseConnection iDatabaseConnection = getConnection( con );
    DatabaseOperation.CLEAN_INSERT.execute(iDatabaseConnection, getDataSet());
    DataSourceUtils.releaseConnection( con, dataSource );
}

Exception message:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Exception occurred while getting connection: oracle.ucp.UniversalConnectionPoolException: Invalid life cycle state. Check the status of the Universal Connection Pool

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
vishal
  • 71
  • 2
  • 7

0 Answers0