List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 25 2001 11:00pm
Subject:Re: Getting autoincrement value from insert using JDBC
View as plain text  
On Thu, Jan 25, 2001 at 05:17:03PM -0500, Gary Lyons wrote:
> Hi all,
> 
> If I have an insert statement that adds data to a table that contains an
> autoincrement column, is there a way to get the value of the auto
> increment column without doing an additional query in JDBC ? . I am
> using the org.gjt.mm.mysql driver .

The MM.MySQL documentation says this in the section "Using MySQL
specific functionality":

MySQL has some features that cannot be accessed from the methods provided
in the standard JDBC API. To access them, you need to cast the Statement
or PreparedStatement object you are using to org.gjt.mm.mysql.Statement
or org.gjt.mm.mysql.PreparedStatement respectively.

From either of these classes you can call the methods getLastInsertID()
to get the value created for any AUTO_INCREMENT field, and
getLongUpdateCount() to get the larger update count that MySQL can
produce as a long.
Thread
Getting autoincrement value from insert using JDBCGary Lyons25 Jan
  • Re: Getting autoincrement value from insert using JDBCPaul DuBois26 Jan