Пример #1
0
 public RiderModel getOneRider(String id)
     throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException,
         ParseException {
   ResultSet result = DB.getResultSet("SELECT * FROM riders WHERE riders.id = " + id + ";");
   RiderModel rider = this.fillModel(result).get(0);
   DB.closeCon();
   return rider;
 }
Пример #2
0
 public void updateRider(String id, String text)
     throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
   DB.runQuery(
       "UPDATE `riders` SET "
           + "`text`='"
           + StringEscapeUtils.escapeSql(text)
           + "'"
           + " WHERE id = "
           + id
           + ";");
   DB.closeCon();
 }
Пример #3
0
  public List<RiderModel> getRiderByCount(String id, String count)
      throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException,
          ParseException {
    ResultSet result =
        DB.getResultSet(
            "select * from riders where id != " + id + " order by id desc limit " + count + ";");
    List<RiderModel> riderList = new LinkedList<>();
    while (result.next()) {
      RiderModel temp = new RiderModel();

      temp.setId(result.getInt("id"));
      temp.setText(result.getString("text"));
      riderList.add(temp);
    }
    DB.closeCon();
    return riderList;
  }
Пример #4
0
 public void insertRider(String text)
     throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
   DB.runQuery(
       "INSERT INTO `riders` (`text`) VALUES ('" + StringEscapeUtils.escapeSql(text) + "');");
   DB.closeCon();
 }