示例#1
0
  private int insertData(
      String user_id,
      String service_id,
      String command_code,
      String mlist,
      MsgObject msgObject,
      String mtfree,
      int msgtype,
      String Service_ss_id,
      long lduration) {
    int ireturn = 1;
    Connection connection = null;
    DBPool dbpool = new DBPool();
    // long lmilisec = System.currentTimeMillis();
    String sqlInsert =
        "Insert into "
            + mlist
            + "(user_id, service_id, date,command_code,request_id, message_type,mobile_operator,mt_free,duration) values ('"
            + user_id
            + "','"
            + service_id
            + "','"
            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
            + "','"
            + Service_ss_id
            + "','"
            + msgObject.getLongRequestid()
            + "','"
            + msgtype
            + "','"
            + msgObject.getMobileoperator()
            + "',"
            + mtfree
            + ","
            + lduration
            + ")";

    try {

      connection = dbpool.getConnectionGateway();

      if (DBUtil.executeSQL(connection, sqlInsert) < 0) {
        Util.logger.error(
            this.getClass().getName()
                + ""
                + ": uppdate Statement: Insert  "
                + mlist
                + " Failed:"
                + sqlInsert);
        ireturn = -1;
      }
    } catch (Exception ex) {
      Util.logger.error(this.getClass().getName() + ":Insert  " + mlist + " Failed");
      ireturn = -1;
      Util.logger.printStackTrace(ex);
    } finally {
      dbpool.cleanup(connection);
    }
    return ireturn;
  }
示例#2
0
  public String getContent6(
      String database, String type, String subcode1, String subcode2, String newstypecode) {

    Connection connection = null;
    DBPool dbpool = new DBPool();
    String content = "content_short";
    String strResult = "";

    // Xac dinh bang nao can lay du lieu
    if ("3".equalsIgnoreCase(type)) {
      content = "content_vi";
    } else if ("2".equalsIgnoreCase(type)) {
      content = "content";
    }

    // String query =
    // "SELECT ID,CONTENT FROM icom_textbase_data WHERE upper(gameid) = '"
    // + textbaseid.toUpperCase() + "'";
    String query =
        "SELECT "
            + content
            + " FROM ( SELECT TOP 1 * FROM newsagri_news_info WHERE status=1 AND type=2 AND  upper(newstypecode) = '"
            + newstypecode.toUpperCase()
            + "'";

    // query = query + " and order =" + lastcode + " ";
    if (!"".equalsIgnoreCase(subcode1)) {
      query += " AND upper(subcode1)='" + subcode1.toUpperCase() + "'";
    }
    if (!"".equalsIgnoreCase(subcode2)) {
      query += " AND upper(subcode2)='" + subcode2.toUpperCase() + "'";
    }
    query += ")x";

    Util.logger.info("Query Content 6: " + query);

    try {
      connection = dbpool.getConnection(database);
      Vector result = DBUtil.getVectorTable(connection, query);

      Util.logger.info(this.getClass().getName() + "getContent: queryStatement:" + query);

      if (result.size() > 0) {

        // record = (String[]) result.get(0);

        Vector item = (Vector) result.elementAt(0);
        strResult = (String) item.elementAt(0);
        return strResult;
      }

      return strResult;
    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + "getContent: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);
      return strResult;
    } finally {
      dbpool.cleanup(connection);
    }
  }
示例#3
0
  // Vi du truyen cuoi
  public String[] getContent0(String database, String type, String lastcode, String newstypecode) {

    String[] record = new String[2];
    record[0] = "";
    record[1] = "";

    Connection connection = null;
    DBPool dbpool = new DBPool();
    String content = "content_short";

    // Xac dinh bang nao can lay du lieu
    if ("3".equalsIgnoreCase(type)) {
      content = "content_vi";
    } else if ("2".equalsIgnoreCase(type)) {
      content = "content";
    }

    Util.logger.info("content = " + content);

    String query =
        "SELECT ID,"
            + content
            + " FROM ( SELECT TOP 1 * FROM newsagri_news_info WHERE upper(newstypecode) = '"
            + newstypecode.toUpperCase()
            + "'";

    query = query + " and id not in (" + lastcode + ") )x ";

    try {
      connection = dbpool.getConnection(database);

      Util.logger.info("SQL Query get content: " + query);
      Vector result = DBUtil.getVectorTable(connection, query);

      Util.logger.info(
          this.getClass().getName() + "getContent: queryStatement:" + result.size() + "@" + query);

      if (result.size() > 0) {

        // record = (String[]) result.get(0);

        Vector item = (Vector) result.elementAt(0);
        record[0] = (String) item.elementAt(0);
        record[1] = (String) item.elementAt(1);

        Util.logger.info(this.getClass().getName() + "getContent: record[0]:" + record[0]);
        Util.logger.info(this.getClass().getName() + "getContent: record[1]:" + record[1]);
        return record;
      }

      return record;
    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + "getContent: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);
      return record;
    } finally {
      dbpool.cleanup(connection);
    }
  }
示例#4
0
  @SuppressWarnings("unchecked")
  private String getContent2(String dbcontent, String type, String infoid, String sDate) {

    Connection connection = null;
    DBPool dbpool = new DBPool();

    try {

      connection = dbpool.getConnection(dbcontent);
      String content = "content_short";
      // Xac dinh bang nao can lay du lieu
      if ("3".equalsIgnoreCase(type)) {
        content = "content_vi";
      } else if ("2".equalsIgnoreCase(type)) {
        content = "content";
      }

      String query =
          "SELECT "
              + content
              + " FROM ( SELECT TOP 1 * FROM newsagri_news_info WHERE status=1 AND type=1 AND upper(newstypecode) = '"
              + infoid.toUpperCase()
              + "' AND CONVERT(varchar(25), [isdate], 103) <='"
              + sDate
              + "' order by [isdate] desc )x";

      Util.logger.info("Query:" + query);
      Vector result = DBUtil.getVectorTable(connection, query);
      if (result.size() == 0) {
        return null;
      } else {

        for (int i = 0; i < result.size(); i++) {

          Vector item = (Vector) result.elementAt(i);
          return (String) item.elementAt(0);
        }
      }

    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + "getInfo: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);

    } finally {
      dbpool.cleanup(connection);
    }
    return null;
  }
示例#5
0
  String[] getContent0(String lastcode, String textbaseid, String poolname) {

    String[] record = new String[2];
    record[0] = "";
    record[1] = "";

    Connection connection = null;
    DBPool dbpool = new DBPool();

    String query =
        "SELECT ID,CONTENT FROM icom_textbase_data WHERE upper(gameid) = '"
            + textbaseid.toUpperCase()
            + "'";

    query = query + " and id not in (" + lastcode + ")  order by rand() limit 1";

    try {
      connection = dbpool.getConnection(poolname);
      Vector result = DBUtil.getVectorTable(connection, query);

      Util.logger.info(
          this.getClass().getName() + "getContent: queryStatement:" + result.size() + "@" + query);

      if (result.size() > 0) {

        // record = (String[]) result.get(0);

        Vector item = (Vector) result.elementAt(0);
        record[0] = (String) item.elementAt(0);
        record[1] = (String) item.elementAt(1);

        Util.logger.info(this.getClass().getName() + "getContent: record[0]:" + record[0]);
        Util.logger.info(this.getClass().getName() + "getContent: record[1]:" + record[1]);
        return record;
      }

      return record;
    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + "getContent: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);
      return record;
    } finally {
      dbpool.cleanup(connection);
    }
  }
示例#6
0
  @SuppressWarnings("unchecked")
  private String getContent2(String infoid) {

    Connection connection = null;
    DBPool dbpool = new DBPool();

    try {

      connection = dbpool.getConnection("gateway");

      String query =
          "select content from icom_infoservice where info_type ='"
              + infoid
              + "' and  info_date <= current_timestamp() order by info_date desc limit 1";

      Vector result = DBUtil.getVectorTable(connection, query);
      if (result.size() == 0) {
        return null;
      } else {

        for (int i = 0; i < result.size(); i++) {

          Vector item = (Vector) result.elementAt(i);
          return (String) item.elementAt(0);
        }
      }

    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + "getInfo: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);

    } finally {
      dbpool.cleanup(connection);
    }
    return null;
  }