Re: problem to get nextval of a sequence - Mailing list pgsql-jdbc

From Guillaume Cottenceau
Subject Re: problem to get nextval of a sequence
Date
Msg-id 87zmzyblx3.fsf@meuh.mnc.ch
Whole thread Raw
In response to problem to get nextval of a sequence  (Daniel Schaedler <postgres-jdbc@daniel.schaedler.name>)
Responses Re: problem to get nextval of a sequence  (Daniel Schaedler <postgres-jdbc@daniel.schaedler.name>)
List 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

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Open connections
Next
From: Daniel Schaedler
Date:
Subject: Re: problem to get nextval of a sequence