G'day,
I'm just looking to clean up some of my code as i know that at the moment it doesnt follow the best practices. I have the following function which calls my database() class. I know that i need to close my connections and statements im just not too sure how to do it.
If anyone could provide a quick syntax as to how i could set my functions out I'd be very much appreciative.
My current function syntax;
public boolean function(String valueOne, int valueTwo ){
try{
Connection connect = new database().getConnection();
Statement con = connect.createStatement();
String qry = "SELECT * FROM table";
ResultSet res = con.executeQuery(qry);
// Do i close the connection and statement here??
}catch(SQLException ex){
ex.printStackTrace();
}
// OR here??
return added;
}
Regards,
TC