db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominik Jednoralski <twelv...@googlemail.com>
Subject Strange SQLException when trying to read existing row
Date Sun, 16 Aug 2009 22:04:44 GMT
Hi Geeks,

I'm integrating the derby-database into a JAVA-driven web application. I'm
new to derby and I have a problem with the execution of a SELECT-statement.
The returned ResultSet is empty, although the selected row is definitely
stored.

The code below *works*, creates a new table and inserts a dummy row.*
*

   - *CREATE TABLE gaps (gapId int generated by default as identity,
   *MBaseId VARCHAR(256), important INTEGER DEFAULT 0,
   ignore INTEGER DEFAULT 0, data LONG VARCHAR,
   creation TIMESTAMP, lastModified TIMESTAMP)
   - INSERT INTO gaps (data) VALUES ('foo')**

At this position, the row is accessible and everything is fine. Later, when
I want to retrieve this very row via the follwing code, it breaks because
the ResultSet is empty. The methods are both members of the same class and
share the connection and statement, which both are class members.

* ResultSet result = statement.executeQuery("SELECT data "
                        + "FROM gaps WHERE gapId = 1" );

            if (result != null) {

                // breaks with sql-exception: no such row
                String data = result.getString(1);*


Can anyone of you help me with this? I'm pretty confused. Thanks a lot in
advance =)

best

Dominik

Mime
View raw message