Andy, An example of using KeyGenerator:
//Executes the given SQL statement and signals the driver with the // given flag about whether the auto-generated keys produced by // this Statement object should be made available for retrieval stmt.executeUpdate(this.sql, 0); rset = stmt.getGeneratedKeys(); if (rset.next()) { // rset.getInt(1) -> Retrieves the value of the designated column // in the current row of this ResultSet object as an int int lastId = rset.getInt(1); } Regardless Fabricio Garcia Imbrizi Murah Technologies 11 8275 0199 -----Mensagem original----- De: Nathan Maves [mailto:[EMAIL PROTECTED] Enviada em: quinta-feira, 3 de junho de 2004 14:18 Para: Struts Users Mailing List Assunto: Re: MySQL, iBatis, and mysql_insert_id iBatis 2.0 has this ability. The other option is to have a KeyGenerator class that handles all of this for you. Don't use the auto generated keys from mysql. Nathan On Jun 3, 2004, at 11:07 AM, Andy Engle wrote: > Hi all, > > I am working on a Struts app where I will be slapping some stuff into a > database table, and from there I will need to get an insert ID back. I > am using a MySQL database, my database stuff is handled by iBatis, and > I am assuming that I need to use the MySLQ command mysql_insert_id() to > get that ID back so I can use it on secondary inserts which will need > that ID as a key. > > Has anyone ever done anything like this before? If not, what sorts of > methods did you use in this scenario to accomplish this? > > Thanks very much for your help, as always. > > > Andy > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]