Skip site navigation (1) Skip section navigation (2)

sequences in JDBC

From: "Nick Fankhauser" <nickf(at)ontko(dot)com>
To: "pgsql-jdbc" <pgsql-jdbc(at)postgresql(dot)org>
Subject: sequences in JDBC
Date: 2001-09-26 20:47:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
I'm trying to use a sequence via JDBC, but I'm having a problem.

The prepared statement I'm using looks like this:

final String address_lineInsert = "insert into address_line( address_id,
address_line_id, address_line_text) values (?,?,?)";

I set the values like so:


When I do the executeUpdate on the prepared statement, I get this error:

java.sql.SQLException: ERROR:  pg_atoi: error in
"nextval('address_id_seq')": can't parse "nextval('address_id_seq')"

This makes sense to me, and I think I could get around it by locking the
table, max value and then inserting my row... but I wonder if there is a
more graceful way to use sequences in JDBC that I'm missing.

Has someone else already solved this problem? Any ideas?



Nick Fankhauser

    nickf(at)doxpop(dot)com  Phone 1.765.965.7363  Fax 1.765.962.9788
doxpop - Court records at your fingertips -


pgsql-jdbc by date

Next:From: Russ McBrideDate: 2001-09-26 21:20:44
Subject: connection error
Previous:From: Barry LindDate: 2001-09-26 20:28:24
Subject: Re: JDBC update wont, plz help.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group