Resultset pas ouvrir. De vérifier la Validation automatique est DÉSACTIVÉE. Apache Debry

Je suis à l'aide d'apache derby pour ma base de données. Je suis en mesure d'effectuer des insertions dans la base de données. Ce qui suit est l'extrait du code qui tente d'afficher le contenu de ma table 'MAINTAB'. L'instance de java.sql.La connexion est "dbconn'.

    ResultSet word;

    Statement query;

    String getData="SELECT THEWORD FROM MAINTAB";
    try{
        System.out.println(dbconn.getAutoCommit());
        query = dbconn.createStatement();
        word = query.executeQuery(getData);
        query.close();

        dbconn.setAutoCommit(false);
        System.out.println(dbconn.getAutoCommit());

        for(;word.next();)
            System.out.println(word.getString(1));

    }catch(Throwable e){
        System.out.println("Table fetch failed or result data failed");}

Et voici le résultat.

org.apache.derby.jdbc.EmbeddedDriver loaded.
Database testDB connected
true
false
Table fetch failed or result data failed
---SQLException Caught---
SQLState:   XCL16
Severity: 20000
Message:  ResultSet not open. Operation 'getString' not permitted. Verify that autocommit is OFF.
java.sql.SQLException: ResultSet not open. Operation 'getString' not permitted. Verify that autocommit is OFF.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedResultSet.checkIfClosed(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedResultSet.getString(Unknown Source)
Closed connection
at test.ShowData.main(ShowData.java:30)
Caused by: java.sql.SQLException: ResultSet not open. Operation 'getString' not permitted. Verify that autocommit is OFF.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(
Unknown Source)
... 9 more
Database shut down normally

Lors, il est d'abord demandé de vérifier si AUTOCOMMIT est DÉSACTIVÉ, j'ai trouvé dans le Derby de la Documentation de VALIDATION automatique est activée par défaut pour toute connexion. Donc, j'ai éteint à l'aide de dbconn.setAutoCommit(false). Encore, l'erreur est levée.

La sortie avant que l'erreur explique que le jeu de résultats a été récupéré sans aucune erreur. Aussi, veuillez noter que la même erreur se produit même si je n'ai pas mis la Validation automatique de faux. Entre les deux, je suis en cours d'exécution derby sur eclipse.

OriginalL'auteur Sundeep | 2010-10-29