aspose file tools
The moose likes JDBC and the fly likes Insert Query with auto-incrementing key Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Insert Query with auto-incrementing key" Watch "Insert Query with auto-incrementing key" New topic
Author

Insert Query with auto-incrementing key

Chris Weathers
Greenhorn

Joined: May 06, 2005
Posts: 12
I have a users table with a primary key "id" that is set to auto-increment for new insertions. So a new user gets automatically assigned the number of users + 1 for their id.

How does my query from my jsp change in this situation? Do I just leave off the "id" field in the Insert query?
Samuel Cox
Ranch Hand

Joined: Nov 16, 2004
Posts: 96

For oracle, mysql, sqlserver, db2?

For db2, I think we used identity_val_local or something like that. For sqlserver, you leave it off.

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Insert Query with auto-incrementing key
 
Similar Threads
Auto Composite key with Id and version
Primary key violation problem
"Two classes with an association between them" mapping? Need help..
Know auto incremented pimary key
IllegalArgumentException when using clj-record's create function