예제 #1
0
  public List<TCTag> getTags(int count) throws SQLException {
    try {
      Connection conn = DatabaseConnector.getConnection();
      Statement statement = conn.createStatement();

      String sql = "SELECT * from tag limit " + count;
      System.out.println(sql);
      ResultSet ret = statement.executeQuery(sql);

      List<TCTag> retList = new ArrayList<TCTag>();

      while (ret.next()) {
        TCTag tag = new TCTag();
        tag.setTag_id(ret.getInt("tag_id"));
        tag.setTag_name(ret.getString("tag_name"));
        tag.setTag_content(ret.getString("tag_content"));
        tag.setTag_type(ret.getString("tag_type"));
        retList.add(tag);
      }
      return retList;
    } catch (SQLException e) {
      throw e;
    }
  }
예제 #2
0
  public TCTag getTag(int tag_id) throws SQLException {
    try {
      Connection conn = DatabaseConnector.getConnection();
      Statement statement = conn.createStatement();

      String sql = "SELECT * from tag where tag_id=" + SQLParamHelper.formatObjectForSQL(tag_id);
      System.out.println(sql);
      ResultSet ret = statement.executeQuery(sql);

      if (ret.next()) {
        TCTag tag = new TCTag();
        tag.setTag_id(tag_id);
        tag.setTag_name(ret.getString("tag_name"));
        tag.setTag_content(ret.getString("tag_content"));
        tag.setTag_type(ret.getString("tag_type"));

        return tag;
      } else {
        return null;
      }
    } catch (SQLException e) {
      throw e;
    }
  }