We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,703 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Inserting and Java Database Auto Increment Problem

Hello to all java programmers I have a java database problem specifically the auto increment. In my MSAccess I have a table named "Confirm" and in that table I got two fields, the "confirm" which is set to text and the "id" which is set to auto number or auto increment which is also my primary key. In my java application I have a textfield then a button save. If the button is clicked, the text in the textfield will be saved in the database field "confirm" then the id will increment. In my code, what I did is this:

String insert = "insert into Confirm values ('"+confirmation.getText()+"',"+missing code here+")";
st.execute(insert);

confirmation.getText() is my JTextField

I don't know what code to put in "missing code here" in order the program to work and the id will auto increment.

2
Contributors
2
Replies
3 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
nagatron
Junior Poster
107 posts since Aug 2008
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

there is no need to mention auto increment explicitly , it will increment automatically when ever you insert a new row

further more the query must be like this

insert into Confirm(columnname) values(columnvalue)

Hope this Help......

Majestics
Practically a Master Poster
696 posts since Jul 2007
Reputation Points: 209
Solved Threads: 66
Skill Endorsements: 5

Thank you so much. . It did work. . hehe I did it this way:

String insert = "insert into Confirm (confrim) values ('"+confirmation.getText()+"')";
st.execute(insert);

=)

nagatron
Junior Poster
107 posts since Aug 2008
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
Question Answered as of 1 Year Ago by Majestics

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0606 seconds using 2.72MB