prepared statements and sequences

From: Ryan Wexler <ryan(at)wexwarez(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: prepared statements and sequences
Date: 2003-04-02 05:43:07
Message-ID: Pine.LNX.4.44L0.0304012132120.32688-100000@wexwarez.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I am interfacing a postgresql db with jdbc using jdk1.4x on a linux box.
I have two questions/problems that I need help with.

1)Prepared Statments
I am trying to use a prepared statement and am successful except for date
fields. I get a parse error when using the preparedStatement.setDate(x,
java.sql.Date); Is this a postgres thing or a personal problem? Is there
a workaround?

2)Sequences-
I am using sequences as unique identifiers, or rather I should say I would
like to use sequences. I have successfully set up several sequences and
every time i insert an new row it automatically increments itself. My
problem is whenever I insert a row I need to know
what the sequence is that was associated with the row inserted. I
can't rely on doing a
max(sequenceid) kind of query because there maybe 10 rows inserted in that
time. My method of inserting rows is just using a prepared statement and
in my insert statement i don't reference the sequence. Is there a way to
get it to return the sequence id say when you call executeUpdate() on the
prepared statement? Or what is the proper way to do this?

thanks a ton
ryan

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Paul Sorenson 2003-04-02 06:17:46 Re: PLS HELP in connecting with jdbc driver
Previous Message Felipe Schnack 2003-04-01 21:00:06 preparedstatment pooling