Re: problem to get nextval of a sequence

From: Guillaume Cottenceau <gc(at)mnc(dot)ch>
To: Daniel Schaedler <postgres-jdbc(at)daniel(dot)schaedler(dot)name>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: problem to get nextval of a sequence
Date: 2004-12-28 13:19:04
Message-ID: 87zmzyblx3.fsf@meuh.mnc.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Daniel Schaedler <postgres-jdbc 'at' daniel.schaedler.name> writes:

> Hi List
>
> I try to get the 'nextval' of a sequence:
> ***
> String query = "SELECT nextval('nodes_nodeid_seq')";
> pstmt = conn.prepareStatement(query);
> logger.debug("statement: " + pstmt.toString());
> ResultSet ress = pstmt.executeQuery();
> long newID = ress.getLong("nextval"); // <-- Exception
> ***
>
> I get the following Exception:
> ***
> org.postgresql.util.PSQLException: ResultSet not positioned properly,
> perhaps you need to call next.

"perhaps you need to call next".

Have you tried calling next?

--
Guillaume Cottenceau

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Daniel Schaedler 2004-12-28 13:32:59 Re: problem to get nextval of a sequence
Previous Message Dave Cramer 2004-12-28 13:09:52 Re: Open connections