wood burning stoves*
The moose likes JDBC and the fly likes Insert Query with auto-incrementing key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
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://aspose.com/file-tools
 
subject: Insert Query with auto-incrementing key