public static ProgramType get(String programTypeName) {
try {
String sql = "select program_type_id, program_type from program_types where program_type = ?";
ProgramType programType = null;
try (Connection connection = DriverManager.getConnection(Utils.getCloudSqlURL())) {
try (PreparedStatement ps = connection.prepareStatement(sql)) {
ps.setString(1, programTypeName.toLowerCase());
try (ResultSet resultSet = ps.executeQuery()) {
while (resultSet.next()) {
programType = new ProgramType();
programType.id = resultSet.getInt(1);
programType.name = resultSet.getString(2);
}
}
}