Is there any condition under which a SQL INSERT statement executed with the method executeUpdate
on a PreparedStatement
object would return 0 without throwing an SQLException?
For example:
String query = "INSERT INTO mytable (column1,column2) VALUES (5,6)";
PreparedStatement preparedStatement = connection.prepareStatement(query);
if(preparedStatement.executeUpdate()!=1){
// A strange error has occurred
} else{
// do what ever
}
Why do I ask? I currently always check to ensure the number of rows returned is equal to 1 but I wonder if that is overkill if it should never return anything but 1.