well, that'll teach me not to update my java api bookmarks to 1.4.... 

the getGeneratedKeys() calls works like a charm!

Thanks for the help

> -----Original Message-----
> From: Mark Matthews [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 02, 2003 4:09 PM
> To: Dan Greene
> Cc: [EMAIL PROTECTED]
> Subject: Re: Auto Increment ID of Inserted Row
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Dan Greene wrote:
> 
> > (newbie to MySQL)
> >
> > I've been banging my head against the wall on this one for 
> a bit now,
> and I understand that last_insert_id() is per-connection 
> based, but most
> webapps are connection pooled (simple) or clustered (harder). 
>  What are
> my options to get the id of the inserted row in a webapp? As a side
> note, I'm using JDBC to access the DB.
> >
> > my thoughts:
> > 1- use an innoDB table, start a txn (lock the table), insert, select
> max(id_column), end txn (unlock the table)
> >
> > 2- make an id pool table (innodb), have app server grab 
> pool of ids at
> startup, and when pool is empty in similar manner (lock, 
> update, select,
> unlock)
> >
> > 3- look to other product (don't make me do this one!!!! ;) )
> >
> > 4- continue to bang head against the wall
> >
> >
> > please cc me on any replies, as although I sent a subscription
> request, I'm not on list yet...
> 
> Is there a reason you don't hold on to the same connection during the
> lifespan of one of your web 'transactions'? Also, to avoid a 
> round trip
> to the server you should use Statement.getGeneratedKeys().
> 
>       -Mark
> 
> - --
> Mr. Mark Matthews
> MySQL AB, Software Development Manager, J2EE and Windows Platforms
> Office: +1 708 557 2388
> www.mysql.com
> 
> Are you MySQL Certified?
> http://www.mysql.com/certification/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD8DBQE/VPjstvXNTca6JD8RAs3RAKC6T+RQnStioRLAJ1cwHHsBMwuPxgCeJU+N
> co0jO0c6pCDxIwxMAHaHkCk=
> =Nkgp
> -----END PGP SIGNATURE-----
> 
> 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to