I have a DBconnector class that I've written. Here is an instance of it using an insert query method it has. Ignore the query for now:
ResultSet NewCustomer = db.executeInsert("SELECT s Bookings VALUES (surnameOut,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger')");
At the moment the above line is getting a "Unhandled exception type SQLException" error. It suggests that I surround the above with a try/catch statement, or give the method that hold's the code a throws exception. I was hoping there was some way to sort it out from within the DBconnector class, so that I can maintain tiny, single lines for executing SQL queries. Is this possible?
Here is the code from the method executeInsert method:
public ResultSet executeInsert(String query)throws SQLException {
Statement s = null;
ResultSet rs = null;
try{
s = con.createStatement();
s.executeQuery(query);
rs = s.getResultSet();
}
catch(SQLException e){}
return rs;
}