示例#1
0
 @Override
 public String getModifyStatement() {
   Topic topic = (Topic) this.getEntity();
   Timestamp ts = new Timestamp(topic.getDate().getTime());
   String statement =
       String.format(
           MODIFY_STATEMENT,
           topic.getUserId(),
           topic.getTitle(),
           topic.getContent(),
           topic.getReplyCount(),
           topic.getDiggCount(),
           ts.toString(),
           topic.getId());
   return statement;
 }
示例#2
0
 @Override
 public String getInsertStatement() {
   Topic topic = (Topic) this.getEntity();
   long userId = topic.getUserId();
   String title = topic.getTitle();
   String content = topic.getContent();
   EntityFactory ef;
   Long topicId;
   String statement;
   try {
     Connection conn = DriverManager.getConnection("proxool.mysql");
     ef = new EntityFactory(conn);
     ResultSet rs = ef.executeQuery("SELECT MAX(topicId) FROM topic");
     rs.next();
     topicId = rs.getLong(1) + 1;
     statement = String.format(TopicWrapper.INSERT_STATEMENT, topicId, userId, title, content);
     conn.close();
     return statement;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }