How to handle Throw exception + close connection I have a function that works with a database. If something wrong happens I want to throw an exception, and I also want that all resources have to be closed. 

Is this a good way to do it? There is a better way to do it?

public Strint getStuff(Integer id) throws Exception {

    String result = "";

    Connection connection = db.openConection();
    ResultSet rs = null;

    try {
       // DO STUFF WITH DB
    } catch (Exception e) {
        throw e;
    } finally {
        rs.close();
        db.closeConection(connection);
    }
    return result;
}
You can skip catch part of try-catch-finally block
You should check that rs is not null