I'm trying to create a small test java restful web service to insert a record into the database. My table is:
test (id int(5) PRIMARY KEY AUTO_INCREMENT, name varchar(10))
When I try the following (with id changed every time), it works:
PreparedStatement stmt;
stmt = con.prepareStatement("insert into test (id,name) values (?,?)");
stmt.setInt(1, 1);
stmt.setString(2, "test");
stmt.executeUpdate();
But when I'm trying to do this, its not working:
PreparedStatement stmt;
stmt = con.prepareStatement("insert into test (name) values (?)");
stmt.setString(1, "test");
stmt.executeUpdate();
Aucun commentaire:
Enregistrer un commentaire