Usuń szablon z kodu db

Wydaje się, że za każdym razem, gdy chcę wykonać zapytanie db, muszę napisać:

Connection conn = null;
Statement stmt = null;
ResultSet rset = null;

try {
    conn = dataSource.getConnection();
    stmt = conn.prepareStatement(sql);
    // ...set stmt params
    rset = stmt.executeQuery();
    while(rset.next()) {
        // Do something interesting
    }
} finally {
    try { if (rset != null) rset.close(); } catch(SQLException e) { }
    try { if (stmt != null) stmt.close(); } catch(SQLException e) { }
    try { if (conn != null) conn.close(); } catch(SQLException e) { }
}

Czy to naprawdę najlepszy sposób na to? Czy istnieje sposób, aby przynajmniej zmniejszyć część bałaganu?

Edytowane: jak wskazywały niektóre komentarze, kod ten nie był długidość.

questionAnswers(5)

yourAnswerToTheQuestion