Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.databases > #51 > unrolled thread
| Started by | "BoBi" <bobi@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:21 +0000 |
| Last post | 2011-04-27 15:21 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.java.databases
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Getting a Mysql auto "BoBi" <bobi@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: Getting a Mysql auto "Jim Garrison" <jim.garrison@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: Getting a Mysql auto "=?ISO-8859-1?Q?Arne_Vajh=" <=?iso-8859-1?q?arne_vajh=@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
| From | "BoBi" <bobi@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:21 +0000 |
| Subject | Re: Getting a Mysql auto |
| Message-ID | <be70739a-a825-45d5-9fb0-625bf0169050@k37g2000hsf.googlegroups.com> |
To: comp.lang.java.databases On Apr 20, 3:23 am, Arne Vajh=F8j <a...@vajhoej.dk> wrote: > Lew wrote: > > BoBi wrote: > >> ResultSet rs =3D pstmt.getGeneratedKeys(); > > > If only you were using PostgreSQL, you could use their extension to the > > INSERT command: > > [ RETURNING * | output_expression [ AS output_name ] [, ...] ] > > But since we of course try to write database independent code, then > we will not use that even if our current database happen to > be PostgreSQL ... > > The getGeneratedKeys method is database independent - it just require > a JDBC 3.0 compliant driver. > > Arne I totally agree. :c), BoBi --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Jim Garrison" <jim.garrison@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:21 +0000 |
| Message-ID | <481bd982$0$12899$4c368faf@roadrunner.com> |
| In reply to | #51 |
To: comp.lang.java.databases BoBi wrote: > On Apr 20, 3:23 am, Arne Vajhoj <a...@vajhoej.dk> wrote: >> Lew wrote: >>> BoBi wrote: >>>> ResultSet rs = pstmt.getGeneratedKeys(); >>> If only you were using PostgreSQL, you could use their extension to the >>> INSERT command: >>> [ RETURNING * | output_expression [ AS output_name ] [, ...] ] >> But since we of course try to write database independent code, then >> we will not use that even if our current database happen to >> be PostgreSQL ... >> >> The getGeneratedKeys method is database independent - it just require >> a JDBC 3.0 compliant driver. Try comparing the Oracle and MSSQL implementations of this supposedly "database independent" feature. Oracle gets it right and supports the API: you provide an array of column names in the PrepareStatement(), and Oracle returns their values for the newly inserted row. MSSQL throws a SQLException if the array contains more than one element, and always returns the single "identity" column value regardless of the column name you specified. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "=?ISO-8859-1?Q?Arne_Vajh=" <=?iso-8859-1?q?arne_vajh=@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:21 +0000 |
| Message-ID | <482b8f98$0$90264$14726298@news.sunsite.dk> |
| In reply to | #54 |
To: comp.lang.java.databases Jim Garrison wrote: > BoBi wrote: >> On Apr 20, 3:23 am, Arne Vajhoj <a...@vajhoej.dk> wrote: >>> Lew wrote: >>>> BoBi wrote: >>>>> ResultSet rs = pstmt.getGeneratedKeys(); >>>> If only you were using PostgreSQL, you could use their extension to the >>>> INSERT command: >>>> [ RETURNING * | output_expression [ AS output_name ] [, ...] ] >>> But since we of course try to write database independent code, then >>> we will not use that even if our current database happen to >>> be PostgreSQL ... >>> >>> The getGeneratedKeys method is database independent - it just require >>> a JDBC 3.0 compliant driver. > > Try comparing the Oracle and MSSQL implementations of this supposedly > "database independent" feature. Oracle gets it right and supports > the API: you provide an array of column names in the PrepareStatement(), > and Oracle returns their values for the newly inserted row. MSSQL > throws a SQLException if the array contains more than one element, and > always returns the single "identity" column value regardless of the > column name you specified. It has to because that is what SQLServer does. Portable database code will assume only one auto generated column, because half the databases only support that. From what you say there is a bug where it does not throw an exception the if the specified column index is not the actual identity column. That bug should obviously be fixed. But the JDBC driver can not by magic make non standard features work on a database that does not support it. Arne --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.databases
csiph-web