db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sai Pullabhotla <sai.pullabho...@jmethods.com>
Subject Re: Strange SQLException when trying to read existing row
Date Mon, 17 Aug 2009 12:13:31 GMT
When a ResultSet is produced, the cursor is positioned before the
first row. You must call ResultSet.next() method to move the cursor to
the first row and then the ResultSet.getXXX methods for each column.
Can you verify/confirm if your code is setup to do this?


Sai Pullabhotla

On Sun, Aug 16, 2009 at 5:04 PM, Dominik
Jednoralski<twelve02@googlemail.com> wrote:
> 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,
> 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

View raw message