GenericJDBCException (invalid column index) with DBUnit & Oracle Express 11g XE

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

GenericJDBCException (invalid column index) with DBUnit & Oracle Express 11g XE

wabrit
Hi

I'm using DBUnit 2.4.9 with version 1.6 of the Oracle JDBC driver against Oracle Express 11g and getting a GenericJDBCException which is causing my test to fail. The stack trace is this:

org.hibernate.exception.GenericJDBCException: Invalid column index
        at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:1263)
        at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
        at $Proxy110.getString(Unknown Source)
        at org.dbunit.util.SQLHelper.createColumn(SQLHelper.java:404)
        at org.dbunit.database.DatabaseTableMetaData.getColumns(DatabaseTableMetaData.java:333)
        at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:106)
        at org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOperation.java:89)
        at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:143)

From what I can make out, the culprit are these lines of the SQLHelper.createColumn method:

        // This is only available since Java 5 - so we ca try it and if it does not work default it
        String isAutoIncrement = Column.AutoIncrement.NO.getKey();
        try {
            isAutoIncrement = resultSet.getString(23);
        }
        catch(SQLException e){

The getString method is throwing a org.hibernate.exception.GenericJDBCException rather than an instance of SQLException, so it doesn't get caught by the block, bubbles up and causes the test to fail.

Any help/guidance much appreciated.

Many thanks

Alan