| From: | Kris Jurka <books(at)ejurka(dot)com> |
|---|---|
| To: | "Chen, Dongdong (GE Healthcare, consultant)" <Dongdong(dot)Chen(at)ge(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org |
| Subject: | Re: [JDBC] need help of getting PK after insertRow in JDBC |
| Date: | 2008-09-26 05:39:50 |
| Message-ID: | Pine.BSO.4.64.0809260134130.24419@leary.csoft.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-jdbc |
On Fri, 26 Sep 2008, Chen, Dongdong (GE Healthcare, consultant) wrote:
> I am a software engineer from GE. I am using JDBC to operate
> PostgreSQL8.3 in Ubuntu8.04. The develop environment is Eclipse3.2 My
> problem is:
> There is a PostgreSQL table XX containing 5 fields: AA, BB, CC, DD,
> EE, AA is primary key and auto-generated type, BB, CC, DD and EE is
> string type.
> I want to get the value of AA immediately after insert a row into
> the table. the code is like this:
>
> Statement st = db.creatStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
> ResultSet.CONCUR_UPDATABLE);
The JDBC driver does not implement true SCROLL_SENSITIVE cursors. The
driver copies the values you provide into its ResultSet and sends the
query to the backend. On the server the auto-generated values are filled
in, but the JDBC driver doesn't get any notification of that. Perhaps
with newer server versions we can make it issue a INSERT ... RETURNING ...
so that we get that data.
> I am not sure it is proper to send this mail to this mail list. Sorry if
> bring you any inconvenience.
Generally cross posting should be avoided and JDBC/Java questions should
be directed to the -jdbc list, but this is a very good question and one
that does prompt further investigation about what can be done in the JDBC
driver to make this better.
Kris Jurka
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joey K. | 2008-09-26 06:46:00 | ]OT] Database structure question |
| Previous Message | Andrew | 2008-09-26 02:18:19 | Re: Oracle and Postgresql |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Aggarwal | 2008-09-29 08:32:26 | Postgres Giving Errors Incomplete Startup Packet |
| Previous Message | Kris Jurka | 2008-09-26 05:15:20 | Re: Newby Question - accessing refcursor. |