public static List<Advancement> findAllAdvancements() { if (!connector.checkForDataBaseConnection()) { return null; } List<Advancement> advancementList = new ArrayList<Advancement>(); try { Statement statement = connector.createStatement(); ResultSet rs = statement.executeQuery("SELECT * FROM advancement ORDER BY name"); while (rs.next()) { Advancement advancement = new Advancement(); advancement.setId(rs.getInt(KeyConst.ADVANCEMENT_ID.getName())); advancement.setName(rs.getString(KeyConst.ADVANCEMENT_NAME.getName())); advancement.setImgPath(rs.getString(KeyConst.ADVANCEMENT_IMG_PATH.getName())); advancementList.add(advancement); } } catch (Exception e) { return null; } return advancementList; }
public static Advancement findByName(String name) { if (!connector.checkForDataBaseConnection()) { return null; } Advancement advancement = null; try { Statement statement = connector.createStatement(); ResultSet rs = statement.executeQuery("SELECT * FROM advancement WHERE name LIKE '" + name + "'"); if (rs.next()) { advancement = new Advancement(); advancement.setId(rs.getInt(KeyConst.ADVANCEMENT_ID.getName())); advancement.setName(rs.getString(KeyConst.ADVANCEMENT_NAME.getName())); advancement.setImgPath(rs.getString(KeyConst.ADVANCEMENT_IMG_PATH.getName())); } } catch (Exception e) { return null; } return advancement; }