Getting autoincrement value from insert using JDBC

2001-01-25 Thread Gary Lyons

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 .

Thanks


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Getting autoincrement value from insert using JDBC

2001-01-25 Thread Paul DuBois

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.

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php