db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag Wanvik <dag.wan...@oracle.com>
Subject Re: [jira] [Commented] (DERBY-5545) Exception ResultSet not open. Operation 'next' not permitted. Verify that autocommit is OFF exception occuring on rs.next() after long run.
Date Mon, 10 Sep 2012 15:39:15 GMT

> Sequence of events
>
> Connection created
> query executed, resultSet obtained (1 record)
> rs.next()
> --savepoint set
> --query executed, resulSet obtained (1 record)
> --savepoint rollback
> rs.next() ->  exception (I would expect false to be returned).
>
> Now, I can reproduce this every single time.  If I change the savepoint rollback to a
releaseSavepoint then it works.  This must be a bug I think?

In this case, the rollback aborts the transaction, so the first result 
set is closed when the final next is attempted.
  Cf code:

     public static void main(String[] args) throws SQLException {
         PreparedStatement ps;
         Connection c = 
DriverManager.getConnection("jdbc:derby:wombat;create=true");
         if (c.getWarnings() == null) {
             ps = c.prepareStatement("create table t(i int)");
             ps.executeUpdate();

             ps =c.prepareStatement("insert into t values 1,2,3,4,5,6");
         }

         ps = c.prepareStatement("select * from t where i=1");
         c.setAutoCommit(false);
         ResultSet rs = ps.executeQuery();
         rs.next();
         Savepoint sp = c.setSavepoint();
         ResultSet rs2 = c.createStatement().executeQuery("select * from 
t where i=3");
         // c.rollback();    // closes transaction, releaseSavepoint 
does not
         c.releaseSavepoint(sp);
         rs.next();             // throws iff we use rollback above

so I believe this behavior is correct. The exception seen w/rollback 
states this clearly:

"Exception in thread "main" java.sql.SQLException: ResultSet not open. 
Operation 'next' not permitted. Verify that autocommit is off."

Of course, the bit about auto-commit is misleading here.

Thanks,
Dag




>
>> Exception ResultSet not open. Operation 'next' not permitted. Verify that autocommit
is OFF exception occuring on rs.next() after long run.
>> --------------------------------------------------------------------------------------------------------------------------------------------
>>
>>                  Key: DERBY-5545
>>                  URL: https://issues.apache.org/jira/browse/DERBY-5545
>>              Project: Derby
>>           Issue Type: Bug
>>           Components: JDBC
>>     Affects Versions: 10.8.2.2
>>          Environment: OSX 10.6
>>             Reporter: Paul taylor
>>               Labels: derby_triage10_9
>>
>> Im seeing this error occur after loading alot of data into the Database. I can confirm
that autocommit is set to off, and that it occurs on calling  rs.next() immediatlely after
running a query and assigning to  resultset rs. The cdoe is called many times (250,000) and
usually works, then suddenly it starts going wrong, I also using c3po database pooling. Im
wondering if the problem is linked to memory consumption although I have no OutOfMemoryError
occurring
>>
>> Java.sql.SQLException: ResultSet not open. Operation 'next' 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.checkExecIfClosed(Unknown Source)
>> 	at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(Unknown Source)
>> 	at org.apache.derby.impl.jdbc.EmbedResultSet.next(Unknown Source)
>> 	at com.mchange.v2.c3p0.impl.NewProxyResultSet.next(NewProxyResultSet.java:2859)
> --
> This message is automatically generated by JIRA.
> If you think it was sent incorrectly, please contact your JIRA administrators
> For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message