I want to catch SQLException
on the try-catch block of Foo
method and here is my code which is not working actually;
public int Foo() {
try {
DB.delete("table", "fname=" + name);
} catch (SQLException e) {
LOGGER.log(Level.WARNING, e.getMessage());
}
}
public int delete(String table, String conditions) {
int updatedRow = 0;
try {
String sql = "DELETE FROM " + table + " SET " + " WHERE " + conditions;
updatedRow = SPM_Database.opeStmt.executeUpdate(sql);
} catch (SQLException ex) {
System.out.println("message" + ex);
LOGGER.log(Level.WARNING, ex.getMessage());
}
return updatedRow;
}
I've got error from catch-block inside Foo() method in my IDE which is;
Unreachable catch block for
SQLException
This exception is never thrown from the try-block. Why I cannot use the try-catch block? Is that I need to throw SQLException
from delete() function or any ideas?