PreparedStatement statement = null;
try {
connection = ...;
statement = connection.prepareStatement(...);
...
ResultSet resultSet = statement.executeQuery();
...
}
catch(SQLException e) {
Fehlerbehandlung
}
finally {
if(statement != null) // ResultSet wird dadurch ebenfalls geschlossen
try { statement.close(); } catch(Exception e) {}
}