| Author |
Obtaining auto created id upon finishing insert
|
D Rog
Ranch Hand
Joined: Feb 07, 2004
Posts: 471
|
|
I'm working on a customer service system which return a customer a ticket number after placing a request. A ticket number is an id in request table, like: table request id number request string subject string customer_id number I use insert like: I'd like to know ticket id after insertion. Will it be reliable in multi requests environment if I use for getting id under the same transaction the following query: Is there any more elegant way to do that?
|
Get power of your iPod with MediaChest | Minimal J2EE container is here | Light weight full J2EE stack | My blog | Co-author of "Windows programming in Turbo Pascal"
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
|
In JDBC 3, you can use Statement.RETURN_GENERATED_KEYS to have the database return the values. For older versions of JDBC, your solution is best.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
D Rog
Ranch Hand
Joined: Feb 07, 2004
Posts: 471
|
|
|
Cool, thanks.
|
 |
 |
|
|
subject: Obtaining auto created id upon finishing insert
|
|
|