Code Sample
try(
Connection connection = dataSource.getConnection();
var statement = connection.prepareStatement("SELECT id, number FROM Department WHERE id = ?")
) {
ps.setLong(1, departmentID);
try (var rs = statement.executeQuery()) {
while (rs.next()) {
long departmentId = rs.getLong("id");
String number = rs.getString("number");
}
}
}