aspose file tools
The moose likes JDBC and the fly likes get the last ID in the auto incremented field Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "get the last ID in the auto incremented field" Watch "get the last ID in the auto incremented field" New topic
Author

get the last ID in the auto incremented field

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi there
I have a table with a field, ID, and its incremented every time there is a new data entry.

say a user has just completed adding new info - how can i get the ID?

thanks
Peter
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26216
    
  66

Peter,
Take a look at this page. It's for db2, but it works the same in most major databases.


[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
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
it helps!
thanks
Statement.RETURN_GENERATED_KEYS
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: get the last ID in the auto incremented field
 
Similar Threads
error while calling create() method
Get id of auto-number
hashCode for temporarly id ?
To show refresh page after addition functionality
Use of sequence without creating an entity