Hi
when trying to call the next method on a result set generated by a
select statement I get the exception:
java.sql.SQLException: ResultSet not open. Verify that autocommit is OFF.
at
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown
Source)
at
org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ResultSet.next(Unknown Source)
at jpegrobot.Main.main(Main.java:44)
Caused by: org.apache.derby.client.am.SqlException: ResultSet not
open. Verify that autocommit is OFF.
at
org.apache.derby.client.am.ResultSet.checkForClosedResultSet(Unknown
Source)
at org.apache.derby.client.am.ResultSet.nextX(Unknown Source)
... 2 more
Here is the relevant portion of my code:
package jpegrobot;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
/**
*
* @author tcarpent
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//
// connect to database
try { Connection localConnection = null;
Statement localStatement;
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
localConnection =
DriverManager.getConnection("jdbc:derby://localhost:1527/C:/database/mydatabase", "*",
"*");
System.out.println("Data connection obtained");
} catch (Exception e) {
System.err.println("I cannot connect to the database");
System.err.println("Exception: "+e.getMessage());
System.exit(1);
}
String SQLString ="SELECT * FROM WORKFLOW";
localStatement = localConnection.createStatement();
ResultSet resultSet = localStatement.executeQuery(SQLString);
while (resultSet.next()) {
<-- exception at call to next()
My platform is:
------------------ Java Information ------------------
Java Version: 1.6.0_17
Java Vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jre6
Java classpath: C:\Program
Files\Sun\JavaDB\bin\../lib/derby.jar;C:\Program
Files\Sun\JavaDB\bin\../lib/derbynet.jar;C:\Program Files\Sun\J
avaDB\bin\../lib/derbyclient.jar;C:\Program
Files\Sun\JavaDB\bin\../lib/derbytools.jar
OS name: Windows XP
OS architecture: x86
OS version: 5.1
Java user name: tcarpent
Java user home: C:\Documents and Settings\tcarpent
Java user dir: C:\Program Files\Sun\JavaDB\bin
java.specification.name: Java Platform API Specification
java.specification.version: 1.6
--------- Derby Information --------
JRE - JDBC: Java SE 6 - JDBC 4.0
[C:\Program Files\Sun\JavaDB\lib\derby.jar] 10.4.2.1 - (706043)
[C:\Program Files\Sun\JavaDB\lib\derbytools.jar] 10.4.2.1 - (706043)
[C:\Program Files\Sun\JavaDB\lib\derbynet.jar] 10.4.2.1 - (706043)
[C:\Program Files\Sun\JavaDB\lib\derbyclient.jar] 10.4.2.1 - (706043)
------------------------------------------------------
is the result set closed after committing the select statment (why)? I
have tried specifying cursor hold etc?
Thanks
Trevor
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.