Never worked with this, but the directions seem to indicate:
org.gjt.mm.mysql.Statement stmt =
(org.gjt.mm.mysql.Statement)dbConnection.createStatement();
int count = stmt.executeUpdate("INSERT INTO ...");
// here i need to catch the ID that was just created
// in the auto_increment field..
id = stmt.getLastIncrementId()
I don't know the type this method returns, but its probably not to
hard to find out.
Randy
-----Original Message-----
From: Cato, Christopher [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 28, 2001 4:55 PM
To: [EMAIL PROTECTED]
Subject: OT: mm.mysql - getLastInsertID() question
Hello. I'm wondering if anyone here would like to elighten me on
how to use the getLastInsertId() function in the mm.mysql jdbc
driver??
I know it's an offtopic question but if you can help, please do so.
I need to retrieve the auto_increment id of the last row created in
a table. Since there may be concurrent writes to the same table, I
cannot do a "select max(id)" to get it. I need to use the method
in mm.mysql. Only problem is, I just don't know how to use it.
Quoting m.matthews (mm.mysql authour):
--------------------------------------
With my driver, MM.MySQL available at
http://www.worldserver.com/mm.mysql/ you can call get the id`s of
AUTO_INCREMENT inserts by casting your
java.sql.Statement/PreparedStatement to
org.gjt.mm.mysql.Statement/PreparedStatement and calling
getLastInsertID() on it.
--------------------------------------
Now, how do I use this from the following code snippet?
my code:
--------------------------------------
public void createSite(String a, String b, String c)
{
try{
// guess I need to cast this some other way, but how?
Statement stmt = dbConnection.createStatement();
int count = stmt.executeUpdate("INSERT INTO ...");
// here i need to catch the ID that was just created
// in the auto_increment field..
}
catch (SQLException e)
{
log(e.getMessage());
}
}
Regards,
Christopher Cato
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]