wood burning stoves 2.0*
The moose likes JDBC and the fly likes How to use PreparedStatement with Auto_Increment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to use PreparedStatement with Auto_Increment" Watch "How to use PreparedStatement with Auto_Increment" New topic
Author

How to use PreparedStatement with Auto_Increment

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 172
Hello Everyone
I am facing problem to use prepared statement with auto increment primary key. How should we insert values in such table ? Say i have 2 columns where "id" is int type, primary key, not null & auto increment. How should i enter the values in the name column which is of varchar type ?

Thanks !!!
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2231
    
    7

If the "id" is primary key and auto-increment, why do you need to specify it in your code? If you do specify the id then it's not really auto-increment.



K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use PreparedStatement with Auto_Increment
 
Similar Threads
Hibernate: Optimization: id generation & two step insert
Auto Increment ID Field Table in the Oracle Database
insert followed by an update with CompositeUserType
MySQL field is autoincrememnt - insert?
How could I map this if possible?