This kind of goes with my other post, but it is different, so here goes. Let's say I have a table with an auto-incremented field. And when starting a transaction I get the last autoincremented field, then I add 1 to it to get what it will be for my Record. Now, if I set the isolation level to serializable, is that going to protect my autoincremented value so that it is not used by another transaction? Also, is there a better way to handle this? I need the autoincremented field value prior to completing the transaction because I am entering data in 2 tables and need that value for the foreign key. Thanks.
MySQL and God I wish I could use Stored Procedures. But MySQL is taking their time implementing them. But I'm sure you already know that. Thanks for trying to help me. I was beginning to wonder.... BTW - Also using the newest Connector/J [ March 14, 2003: Message edited by: Gregg Bolinger ]
town drunk ( and author)
Joined: Jun 27, 2002
At a high level, I'd suggest a synchronized method to access the db: probably synchronized on a given db lock object, which is maybe a static in a differ class all together. This assumes the no other applications are playing with your table, and that any part of the your code that needs to write to that particular table could synchronize on that variable. Thus, you get atomic behavior. I know the reply's a bit terse, so I'll ask if I've been clear? M