Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Jim Garrison" Subject: Re: Getting a Mysql auto Message-ID: <481bd982$0$12899$4c368faf@roadrunner.com> X-Comment-To: comp.lang.java.databases Newsgroups: comp.lang.java.databases In-Reply-To: References: Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 28 Date: Wed, 27 Apr 2011 15:21:29 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303917689 96.60.20.240 (Wed, 27 Apr 2011 10:21:29 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:21:29 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.databases:54 To: comp.lang.java.databases BoBi wrote: > On Apr 20, 3:23 am, Arne Vajhoj 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