Пример #1
0
 public void save(final WKPaper paper) {
   jdbcAux.execute(
       new StatementCreator() {
         @Override
         public PreparedStatement createStatement(Connection con) throws SQLException {
           PreparedStatement ps =
               con.prepareStatement(
                   "insert into wk_paper(name, description, score, name_publisher)values(?,?,?,?)");
           ps.setString(1, paper.name);
           ps.setString(2, paper.description);
           ps.setInt(3, paper.score);
           ps.setString(4, paper.name_publisher);
           return ps;
         }
       });
 }
Пример #2
0
  public void update(final WKPaper paper) {
    jdbcAux.execute(
        new StatementCreator() {

          @Override
          public PreparedStatement createStatement(Connection con) throws SQLException {
            PreparedStatement ps =
                con.prepareStatement(
                    "update wk_paper set name=?,description=?,score=?,name_publisher=? where id=?");
            ps.setString(1, paper.name);
            ps.setString(2, paper.description);
            ps.setInt(3, paper.score);
            ps.setString(4, paper.name_publisher);
            ps.setInt(5, paper.id);
            return ps;
          }
        });
  }
Пример #3
0
 public void delete(int id) {
   jdbcAux.execute("DELETE from wk_paper where id = ?", id);
   jdbcAux.execute("DELETE from wk_question_meta where id_paper = ?", id);
 }
Пример #4
0
 public void addChapter(int paperId, int chapterId) {
   jdbcAux.execute(
       "insert into r_paper_chapter(id_paper, id_chapter)values(?,?)", paperId, chapterId);
 }
Пример #5
0
 public WKPaper get(int id) {
   return jdbcAux.queryForObject("select * from wk_paper where id = " + id, MAPPING);
 }
Пример #6
0
 public List<WKPaper> getAll() {
   return jdbcAux.queryForList(SELECT, MAPPING);
 }