Note that there are some explanatory texts on larger screens.

plurals
  1. POResultset not open. Verify Autocommit is OFF. Apache Debry
    text
    copied!<p>I am using apache derby for my database. I am able to perform inserts into the database. The following is the excerpt from the code that attempts to display the contents of my only table 'MAINTAB'. The instance of java.sql.Connection is 'dbconn'.</p> <pre><code> 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");} </code></pre> <p>And the following is the output.</p> <pre><code>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 </code></pre> <hr> <p>When, it first asked to verify if AUTOCOMMIT is OFF, I have found from the Derby Documentation that AUTOCOMMIT is turned ON by default to any connection. So, I've turned it off using dbconn.setAutoCommit(false). Still, the error is thrown.</p> <p>The output before the error explains that the result set was fetched without any error. Also, please note that the same error is thrown even if I do not set the AutoCommit to false. Between, I am running derby on eclipse.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload