0
I am running the following java function:
public boolean insert(User user) throws SQLException{
String sql = "insert into usuarios (nome, email, senha) values (?,?,?)";
PreparedStatement instruction = this.connection.prepareStatement(sql);
instruction.setString(1, user.getName());
instruction.setString(2, user.getEmail());
instruction.setString(3, user.getPassword());
boolean result = instruction.execute();
instruction.close();
return result;
}
the problem is that it always returns false in instruction.execute()
but if I select users, it appears that they have been registered.
I understood, but the executionUpdate() returns an int...
– RickPariz
This, this int indicates the number of inserted records, which in this case should be 1 for successful insertion cases. If the insertion has failed, it will return something other than that, which is 0. Anything take a look here: http://docs.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#executeUpdate()
– Tássio Auad
I did it, Obg !
– RickPariz