I have used the following servlet code for over a year and it worked
fine.  When I updated to MySQL v4.1.9 and run "SELECT LAST_INSERT_ID();"
from the command prompt it returns a value of "0".  In phpMyAdmin the
"Table Options - auto_increment" field show a value of "96" which is
correct.

How can I modify this to make it return the correct value for the next
auto_increment field?   (I'm using Connector/J v3.0.16)

    sql.setSqlValue("SELECT LAST_INSERT_ID()");
       sql.setValues(values);
       Result res = sql.executeQuery();
    if (res != null && res.getRowCount() > 0){
       Long id = (Long)res.getRows()[0].get("LAST_INSERT_ID");

Can "getGeneratedKeys()" be used here instead?

Thanks,

Jack

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to