If I want to select stuff in my database I can just executeQuery in a ResultSet and return that to see what I got. But how do I do checks if I want to insert or update rows?
How can I see what the db returned? If it affected anything?
public static boolean doUpdate(String statement) {
openConnection();
try {
stmt = conn.createStatement();
stmt.executeUpdate(statement);
closeConnection();
return true;
} catch (SQLException ex) {
System.out.println(DBhandler.class.getName()+"\n"+ex);
closeConnection();
}
return false;
}
I have tried to give the function a boolean return value, but the code in try will continue no matter if the update/insert worked or not.