Search code examples
informixschemaspy

SchemaSpy - Error message while generating the report


I am using SchemaSpy (5.0.0) to generate a report of our Informix database. While running it I get the following error during the last step of 'Gathering schema details':

java.sql.SQLException: The cursor has been previously released and is unavailable.
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:408)
    at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3187)
    at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3467)
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2378)
    at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2303)
    at com.informix.jdbc.IfxSqli.executeFetch(IfxSqli.java:2037)
    at com.informix.jdbc.IfxSqli.getaRow(IfxSqli.java:4077)
    at com.informix.jdbc.IfxResultSet.next(IfxResultSet.java:494)
    at com.informix.jdbc.IfxDatabaseMetaData.getImportedKeys(IfxDatabaseMetaData.java:5524)
    at net.sourceforge.schemaspy.model.Table.connectForeignKeys(Table.java:106)
    at net.sourceforge.schemaspy.model.Database.connectTables(Database.java:984)
    at net.sourceforge.schemaspy.model.Database.<init>(Database.java:83)
    at net.sourceforge.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:211)
    at net.sourceforge.schemaspy.Main.main(Main.java:42)
Caused by: java.sql.SQLException
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:408)
    at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3472)

I am using the Informix JDBC driver in version 4.1.0 (also tried 4.10.8.1). Strangely this driver also needs the BSON library.

Any idea what's the problem?


Solution

  • I just answered this similar question here https://stackoverflow.com/a/55458418/8334122. The copy of that answer is below.

    I had to get some help tracking down this as it's a timing issue + bug in the driver.

    The problem here is with some versions of the Informix JDBC driver. Quick fix is to upgrade to the latest 4.50.1 driver. It's out on maven.

    <!-- https://mvnrepository.com/artifact/com.ibm.informix/jdbc -->
    <dependency>
        <groupId>com.ibm.informix</groupId>
        <artifactId>jdbc</artifactId>
        <version>4.50.1</version>
    </dependency>
    

    In detail. The 4.10.X drivers introduced a statement cleaner thread that runs every 15 seconds and looks for resources that need to be closed as they have no more references and could be garbage collected. The problem, then compounds as a couple JDBC metdata calls incorrectly failed to close resources causing this cleaner thread to close resources in the middle of the work sometimes. Hence some people see it often, some never. You can work around it with 4.10.JC12 where we added a connection flag to disable the cleaner thread (IFMXCONNECTION_CLEANER_THREADS=0). Or the best option is to upgrade to the newest 4.50.1 driver which has this issue properly fixed