db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trevor Carpenter <trevor.carpen...@ed.ac.uk>
Subject Solved: problem with select statement?
Date Mon, 04 Jan 2010 15:15:17 GMT
Problem solved

I was issuing an update using the same connection.

Thanks for all those that helped

Trevor


Quoting Trevor Carpenter <trevor.carpenter@ed.ac.uk>:

> Hi
>
> It transpires that the exception for the method ResultSet.next is only
> generated when the select statement includes a column PATH of
> VARCHAR(128) and other columns -
>
> No Exception:
> select PRIMARYKEY,PROCESSED,PROCESSED_DATE,PROCESSED_TIME from WORKFLOW
>
> No Exception:
> select PATH from WORKFLOW
>
> Exception:
> select PATH,PRIMARYKEY from WORKFLOW
>
> Any suggestions
>
> Trevor.
>
> Quoting Trevor Carpenter <trevor.carpenter@ed.ac.uk>:
>
>> 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.
>
>
>
> Trevor Carpenter
>
> Telephone: 0131-537-2663
> Mobile: 07791277210
>
> SFC Brain Imaging Research Centre
> Clinical Neurosciences
> Western General Hospital
> Edinburgh
> EH4 2XU
>
> www.sbirc.ed.ac.uk
>
> The SFC Brain Imaging Research Centre is part of the SINAPSE collaboration,
> (Scottish Imaging Network, A Platform for Scientific Excellence.
> www.sinapse.ac.uk)
>
>
>
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.



Trevor Carpenter

Telephone: 0131-537-2663
Mobile: 07791277210

SFC Brain Imaging Research Centre
Clinical Neurosciences
Western General Hospital
Edinburgh
EH4 2XU

www.sbirc.ed.ac.uk

The SFC Brain Imaging Research Centre is part of the SINAPSE collaboration,
(Scottish Imaging Network, A Platform for Scientific Excellence.  
www.sinapse.ac.uk)



-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



Mime
View raw message