Beispiel #1
0
  public void updateTag(TCTag tag) throws SQLException {
    try {
      Connection conn = DatabaseConnector.getConnection();
      Statement statement = conn.createStatement();

      String sql =
          "UPDATE tag set tag_name="
              + SQLParamHelper.formatStringForSQL(tag.getTag_name())
              + ", tag_content="
              + SQLParamHelper.formatStringForSQL(tag.getTag_content())
              + ", tag_type="
              + SQLParamHelper.formatStringForSQL(tag.getTag_type())
              + " where tag_id="
              + SQLParamHelper.formatObjectForSQL(tag.getTag_id());
      System.out.println(sql);
      statement.executeUpdate(sql);
    } catch (SQLException e) {
      throw e;
    }
  }
Beispiel #2
0
  public void insertTag(TCTag tag) throws SQLException {
    try {
      Connection conn = DatabaseConnector.getConnection();
      Statement statement = conn.createStatement();

      String sql =
          "INSERT INTO tag(tag_id, tag_name, tag_content, tag_type)"
              + " VALUES ("
              + SQLParamHelper.formatObjectForSQL(tag.getTag_id())
              + ", "
              + SQLParamHelper.formatStringForSQL(tag.getTag_name())
              + ", "
              + SQLParamHelper.formatStringForSQL(tag.getTag_content())
              + ", "
              + SQLParamHelper.formatStringForSQL(tag.getTag_type())
              + ")";
      System.out.println(sql);
      statement.executeUpdate(sql);
    } catch (SQLException e) {
      throw e;
    }
  }