I am sorry if there is a duplicate but I tried all ways still I can't do the insertion.
I have a table with only two fields ( ID , Name )
When I run this SQL code it must be insert a new record and increment the ID
field automatically
because it's auto increment but unfortunately don't work .
See the trail and errors :
MYSQL :
PreparedStatement pr = con.prepareStatement("insert into names(name) values(?)"); pr.setString(2,"Azad");
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
insert into names(id,name) values(?,?)
java.sql.SQLException: No value specified for parameter 1
MS Access :
insert into names(name) values(?)
java.lang.ArrayIndexOutOfBoundsException: 1
insert into names(id,name) values (?,?)
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
What's the reason of those errors ? and how to solve it ?
Thanks for suggestions and answers.