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 Soft Skills this week in the Jobs Discussion 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: 180
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: 2615
    
    9

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 OCPBCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use PreparedStatement with Auto_Increment