Example #1
0
  private static boolean deletePrice(int price) {

    Connection connection = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }
      String sqlUpdate = "DELETE FROM giadau  WHERE id=" + price;
      Util.logger.info(" DELETE Gia dau: " + sqlUpdate);
      statement = connection.prepareStatement(sqlUpdate);
      if (statement.execute()) {
        Util.logger.info("Loi xoa gia dau ");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #2
0
  private static boolean deleteWinner(int phien) {

    Connection connection = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }
      String sqlUpdate = "DELETE FROM daugia_winner  WHERE phien=" + phien;
      Util.logger.info(" DELETE WINNER: " + sqlUpdate);
      statement = connection.prepareStatement(sqlUpdate);
      if (statement.execute()) {
        Util.logger.info("Loi xoa nguoi duy nhat thap nhat ");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #3
0
  private static boolean saveChat(String fromnick, String tonick, String noidung) {

    Connection connection = null;
    PreparedStatement statement = null;

    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }
      String sqlInsert = "INSERT INTO vtv6_chatketnoi (fromnick,tonick,content)" + "VALUES(?,?,?)";
      statement = connection.prepareStatement(sqlInsert);
      statement.setString(1, fromnick);
      statement.setString(2, tonick);
      statement.setString(3, noidung);

      statement.executeUpdate();
      Util.logger.info("sqlInsert  : " + sqlInsert);
      return true;

    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #4
0
  private static int getPhien() {
    int result = -1;
    Connection cnn = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    ResultSet rs = null;
    String query = "SELECT phien FROM ketnoiphien  where isprocess=1 ";

    try {
      cnn = dbpool.getConnectionGateway();
      statement = cnn.prepareStatement(query);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result = rs.getInt(1);
          return result;
        }
      }
      return result;
    } catch (SQLException ex2) {
      Util.logger.error("GetSequence. Ex:" + ex2.toString());
      return result;
    } catch (Exception ex3) {
      Util.logger.error("GetSequece. Ex3:" + ex3.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(cnn);
    }
  }
Example #5
0
  private static boolean isexist(String userid, String mlist) {
    Connection connection;
    PreparedStatement statement;
    DBPool dbpool;
    connection = null;
    statement = null;
    dbpool = new DBPool();
    try {

      connection = dbpool.getConnectionGateway();

      String query3 = "select * from " + mlist + " where user_id='" + userid + "' ";

      Util.logger.info(query3);
      Vector result3 = DBUtil.getVectorTable(connection, query3);
      if (result3.size() > 0) {
        Vector item = (Vector) result3.elementAt(0);
        return true;
        // tempMilisec = (String) item.elementAt(0);
      }
      return false;

    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      Util.logger.printStackTrace(e);
      return true;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      Util.logger.printStackTrace(e);
      return true;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #6
0
  public static String getMobileOperatorNew(String userid, int type) {

    String tmpOperator = "-";
    Connection connection = null;
    DBPool dbpool = new DBPool();
    try {

      connection = dbpool.getConnection("gateway");

      String query =
          "SELECT operator FROM icom_isdnseries WHERE prefix= substr('"
              + userid
              + "',1, length(prefix)) ";
      if (type == 1 || type == 0) {
        query += " and type=" + type;
      }

      Vector result = DBUtil.getVectorTable(connection, query);
      for (int i = 0; i < result.size(); i++) {
        Vector item = (Vector) result.elementAt(i);
        tmpOperator = (String) item.elementAt(0);
      }

      return tmpOperator;
    } catch (Exception ex) {
      Util.logger.sysLog(
          LogValues.INFORMATIVE,
          "Utils",
          "getMobileOperator: Get MobileOpereator Failed" + ex.toString());
      return tmpOperator;
    } finally {
      dbpool.cleanup(connection);
    }
  }
Example #7
0
  public static String getContent(String Code) {
    // tach lastcode

    String content;
    Connection connection = null;
    DBPool dbpool = new DBPool();
    String query =
        "select Content from [IComStore].[dbo].[SDPText] where Code = '"
            + Code
            + "'  order by CreateDate desc";

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

      Util.logger.info("DBUtil.getCode: queryStatement:" + query);

      if (result.size() > 0) {
        Vector item = (Vector) result.elementAt(0);
        content = item.elementAt(0).toString();
        return content;
      }

    } catch (Exception ex) {
      Util.logger.info("DBUtil.getCode: getContent: Failed" + ex.getMessage());
      Util.logger.printStackTrace(ex);
      return "";
    } finally {
      dbpool.cleanup(connection);
    }
    return "";
  }
Example #8
0
  private static boolean deleteUser(String user, String table) {

    Connection connection = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();

      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }
      String sqlUpdate = "DELETE FROM " + table + "  WHERE user_id='" + user + "'";
      Util.logger.info(" DELETE USER: "******"Loi xoa user " + user + "trong bang " + table);
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #9
0
  private static boolean add2CanceledAds(String userID) {
    boolean OK = false;
    Util.logger.info(className + ".add2CanceledAds()");

    String tablename = "vng_cancel_ads";
    String sSQLInsert = "replace into " + tablename + "(userid)" + " values(?)";

    Connection connection = null;
    PreparedStatement ps = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();

      ps = connection.prepareStatement(sSQLInsert);
      ps.setString(1, userID);
      if (ps.executeUpdate() >= 1) {
        OK = true;
      }
      ps.close();
    } catch (SQLException e) {
      OK = false;
      Util.logger.info(className + ".add2CanceledAds() error:" + e.getMessage());
    } catch (Exception e) {
      OK = false;
      Util.logger.info(className + ".add2CanceledAds() error:" + e.getMessage());
    } finally {
      dbpool.cleanup(connection);
    }

    return OK;
  }
  private static boolean saverequest(String userid, String dtbase, int subcode) {

    Connection connection = null;
    PreparedStatement statement = null;

    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }

      String sqlInsert =
          "INSERT INTO " + dtbase + "(userid, subcode) VALUES ('" + userid + "'," + subcode + ")";
      Util.logger.info("Insert:" + sqlInsert);
      statement = connection.prepareStatement(sqlInsert);
      if (statement.execute()) {
        Util.logger.error("Insert into dbcontent");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #11
0
  private int insertData2cancel(
      String user_id,
      String service_id,
      String command_code,
      String mlist,
      MsgObject msgObject,
      String mtfree,
      int msgtype,
      String Service_ss_id,
      String mt_count) {
    int ireturn = 1;
    Connection connection = null;
    DBPool dbpool = new DBPool();
    // long lmilisec = System.currentTimeMillis();
    String sqlInsert =
        "Insert into "
            + mlist
            + "_cancel(user_id, service_id, date,command_code,request_id, message_type,mobile_operator,mt_free,mt_count) values ('"
            + user_id
            + "','"
            + service_id
            + "','"
            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
            + "','"
            + Service_ss_id
            + "','"
            + msgObject.getRequestid()
            + "','"
            + msgtype
            + "','"
            + msgObject.getMobileoperator()
            + "',"
            + mtfree
            + ","
            + mt_count
            + ")";

    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;
  }
  /* Tim list bai hat */
  private static String findListofMusic(
      String dtbase, String userid, String infoid, String lastid, int subcode) {
    String result = "";
    // String musicid = "";
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnection(dtbase);
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }

      String sqlSelect =
          "SELECT musicname_sms, musicid FROM icom_music WHERE ( upper(operator) = '"
              + infoid.toUpperCase()
              + "')";

      if (!"".equalsIgnoreCase(lastid)) {
        sqlSelect = sqlSelect + " AND musicid not in(" + lastid + ") ";
      }

      Util.logger.info("SEARCH SONG MUSIC : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result = result + rs.getString(1) + "-" + rs.getString(2) + ";";
          if (result.length() > 160) {
            // cap nhat cho khach hang list danh sach da gui
            updateListMusic(userid, lastid, dbcontent, subcode);
            return result;
          } else {
            if ("".equalsIgnoreCase(lastid)) {
              lastid = lastid + rs.getString(2);
            } else {
              lastid = lastid + "," + rs.getString(2);
            }
          }
        }
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
  private static String[] findMusicIDlike(String find, String infoid) {

    String[] result = new String[2];
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;

    DBPool dbpool = new DBPool();
    for (int i = 0; i < 2; i++) {
      result[i] = "";
    }

    try {
      connection = dbpool.getConnection("store");
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }
      String ope = "";
      if (infoid.equalsIgnoreCase("vinaphone")) ope = "VNPCode";
      else if (infoid.equalsIgnoreCase("mobifone")) ope = "VMSCode";
      else ope = "VTCode";

      String sqlSelect =
          "SELECT top 1 RingbackName_E,"
              + ope
              + " FROM [IComStore].[dbo].Ringback WHERE SearchRingbackName LIKE '%"
              + find
              + "%' and "
              + ope
              + " is not null and "
              + ope
              + " <>''";

      Util.logger.info("SEARCH MA SO  : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);
      Util.logger.info("SEARCH MA SO");
      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result[0] = rs.getString(1);
          result[1] = rs.getString(2);
        }
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #14
0
  // Lay noi dung trong icom_textbase_data
  private String getContent(String gameid, String commandcode) {

    // String content = "";
    // String area = "";
    Connection connection = null;
    DBPool dbpool = new DBPool();
    PreparedStatement statement = null;
    ResultSet rs = null;
    // String[] result = null;
    String result = "";

    try {

      connection = dbpool.getConnectionGateway();

      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }

      // Lấy company_id của commandcode
      // /int company_id = getCompanyId(commandcode);
      // String company_name = "";

      String query =
          "SELECT content FROM icom_textbase_data WHERE ( upper(gameid) = '"
              + gameid.toUpperCase()
              + "') AND ( upper(subcode1) ='"
              + commandcode.toUpperCase()
              + "')";
      statement = connection.prepareStatement(query);

      Util.logger.info("LOST MESSAGE" + query);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result = rs.getString(1);
        }
      }
      return result;
    } catch (Exception ex) {
      Util.logger.info(this.getClass().getName() + " SoiCauXoSo: Failed" + ex.getMessage());
      ex.printStackTrace();
      // content = "Ma tinh khong hop le. Soan tin: CAU<Matinh> gui 8551
      // de soi cau chinh xac nhat";
      return result;
    } finally {

      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #15
0
  private static String findListofMusic(String date) {
    String result = "";

    // String musicid = "";
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    DBPool dbpool = new DBPool();
    String lastresult = "";
    try {
      connection = dbpool.getConnection("mediatech");
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }

      String sqlSelect =
          "select top 3 replace(NameVote,' ','') NameVote,Code from PlaysList where DatePlay='"
              + date
              + "' order by newid() ; ";

      Util.logger.info("SEARCH List game : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);

      if (statement.execute()) {
        rs = statement.getResultSet();
        int i = 0;
        while (rs.next()) {

          result =
              result
                  + rs.getString(2).trim()
                  + "_"
                  + rs.getString(1).substring(0, rs.getString(1).length() - 4)
                  + ";";
        }

        return result;
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
  /* ghi lai dsach khach hang */
  private static boolean saveClient(
      String userid,
      String operator,
      String keyword,
      String serviceid,
      Timestamp timesend,
      BigDecimal requestid) {
    Connection connection = null;
    PreparedStatement statement = null;

    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }

      String sqlInsert =
          "INSERT INTO icom_list_customer( userid, operator, keyword, serviceid, timesend, requestid) VALUES ('"
              + userid
              + "','"
              + operator.toUpperCase()
              + "','"
              + keyword
              + "','"
              + serviceid.toUpperCase()
              + "','"
              + timesend
              + "','"
              + requestid
              + "')";
      Util.logger.info("Insert:" + sqlInsert);
      statement = connection.prepareStatement(sqlInsert);
      if (statement.execute()) {
        Util.logger.error("Insert into icom_list_customer");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #17
0
  private long getSequence(String gameid, String serviceid) {
    long sequence = 1;

    Connection cnn = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    ResultSet rs = null;
    String query = "select sequence from icom_sequence where gameid='" + gameid.toUpperCase() + "'";

    try {
      cnn = dbpool.getConnectionGateway();
      statement = cnn.prepareStatement(query);

      String sequence_temp = "";
      if (statement.execute()) {
        rs = statement.getResultSet();
        // rs = statement.getResultSet();
        while (rs.next()) {
          sequence_temp = rs.getString(1);
        }
      }

      sequence = Long.parseLong(sequence_temp);
      if (sequence > 0) {
        String sqlUpdate =
            "update icom_sequence set sequence = sequence + 1 where gameid='"
                + gameid.toUpperCase()
                + "'";
        statement = cnn.prepareStatement(sqlUpdate);
        if (statement.executeUpdate() != 1) {
          Util.logger.error("GetSequence: Update icom_sequence Failed");
        }
      }

    } catch (SQLException ex2) {
      Util.logger.error("GetSequence. Ex:" + ex2.toString());

    } catch (Exception ex3) {
      Util.logger.error("GetSequece. Ex3:" + ex3.toString());

    } finally {
      dbpool.cleanup(rs, statement);
      dbpool.cleanup(cnn);
    }

    return sequence;
  }
Example #18
0
  private static String Getmobile(String stt) {
    String result = "";
    // String musicid = "";
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }
      int tam = -1;
      try {
        tam = Integer.parseInt(stt);
      } catch (Exception ex) {

      }
      String sqlSelect = "SELECT userid FROM ketnoi where stt=" + stt;

      Util.logger.info("SEARCH CODE  : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result = rs.getString(1);
          Util.logger.info("Code: " + result);
          return result;
        }
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #19
0
  private int saveWinner(String keyword, String serviceid, String userid, String mttext, int phien)
      throws Exception {

    Connection connection = null;
    PreparedStatement statement = null;
    String sqlString = null;
    DBPool dbpool = new DBPool();
    // Util.logger.info("sendMT:" + msgObject.getUserid()+ "@TO" +
    // msgObject.getServiceid() + "@" + msgObject.getUsertext() );
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return -1;
      }
      String sqlInsert =
          "Insert into daugia_winner (command_code,user_id,service_id,info,phien) values ('"
              + keyword
              + "','"
              + userid
              + "','"
              + serviceid
              + "','"
              + mttext
              + "',"
              + phien
              + ")";
      Util.logger.info("Insert:" + sqlInsert);
      statement = connection.prepareStatement(sqlInsert);
      if (statement.executeUpdate() != 1) {
        Util.logger.info("SieuRe: Insert in to daugia_winner Failed");
        return -1;
      }
      return 1;
    } catch (SQLException e) {
      Util.logger.error("SieuRe: Error:" + e.toString());
      return -1;
    } catch (Exception e) {
      Util.logger.error("SieuRe: Error:" + e.toString());
      return -1;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #20
0
  private static String[] getListblacknick() {
    int max = getmaxlist();
    String[] result = new String[max];

    // String musicid = "";
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    DBPool dbpool = new DBPool();
    String lastresult = "";
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }

      String sqlSelect = "select blacknick from vtv6_blacknick ";

      Util.logger.info("SEARCH List game : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);

      if (statement.execute()) {
        rs = statement.getResultSet();
        int i = 0;
        while (rs.next()) {
          result[i] = rs.getString(1);
          i++;
        }
        return result;
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
  // Tim sdt co trong danh sach da gui tin hay nhan tin hay khong.
  private static String getMusicID(String userid, String dtbase, int subcode) {
    Connection cnn = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    ResultSet rs = null;

    String sequence_temp = "";
    try {
      cnn = dbpool.getConnectionGateway();

      String query =
          "SELECT musichotid FROM "
              + dtbase
              + " WHERE userid= '"
              + userid.toUpperCase()
              + "' AND subcode="
              + subcode;
      if (cnn == null) {
        Util.logger.error("Impossible to connect to DB");
        return sequence_temp;
      }
      statement = cnn.prepareStatement(query);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          sequence_temp = rs.getString(1);
        }
      }
      return sequence_temp;
    } catch (SQLException ex2) {
      Util.logger.error("GetSequence. Ex:" + ex2.toString());
      return sequence_temp;
    } catch (Exception ex3) {
      Util.logger.error("GetSequece. Ex3:" + ex3.toString());
      return sequence_temp;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(cnn);
    }
  }
  /* tim ma so cac bai hat */
  private static List<String> findBirth(String birthday) {
    List<String> lstresult = new ArrayList<String>();
    int code = 0;
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;

    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnection("VOVTV");
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return lstresult;
      }

      String sqlSelect =
          "SELECT NickName FROM [dbo].NickName WHERE Brithday LIKE '" + birthday + "'";

      Util.logger.info("SEARCH THEO BIRTHDAY AND ADDRESS  : " + sqlSelect);
      Vector result = DBUtil.getVectorTable(connection, sqlSelect);

      Util.logger.info("DBUtil.getCode: queryStatement:" + sqlSelect);

      for (int iIndex = 0; iIndex < result.size(); iIndex++) {
        Vector vtRow = (Vector) result.elementAt(iIndex);
        String nick = (String) vtRow.elementAt(0);
        lstresult.add(nick);
      }
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return lstresult;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return lstresult;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
    return lstresult;
  }
Example #23
0
  private static int findCode() {
    int result = 0;
    // String musicid = "";
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }

      String sqlSelect = "SELECT stt FROM ketnoi order by stt desc limit 1";

      Util.logger.info("SEARCH CODE  : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result = rs.getInt(1);
          Util.logger.info("Code: " + result);
          return result;
        }
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #24
0
  // Update khach hang dua ra gia duy nhat va nho nhat
  private static boolean updateWinner(
      String keyword, String serviceid, String userid, String mttext, int phien) {

    Connection connection = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }
      String sqlUpdate =
          "UPDATE daugia_winner  SET command_code ='"
              + keyword
              + " ',user_id= '"
              + userid
              + "',service_id='"
              + serviceid
              + "',info='"
              + mttext
              + "' WHERE phien="
              + phien;
      Util.logger.info(" UPDATE DATE: " + sqlUpdate);
      statement = connection.prepareStatement(sqlUpdate);
      if (statement.execute()) {
        Util.logger.info("Update nguoi trung thuong to send " + userid + " to dbcontent");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
  // cap nhat danh sach khach hang
  private static boolean updateListMusic(String userid, String lastid, String dtbase, int subcode) {

    Connection connection = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }

      // Update cac danh sach bai hat da gui cho khach hang
      String sqlUpdate =
          "UPDATE "
              + dtbase
              + " SET musichotid = '"
              + lastid
              + "' WHERE upper(userid)='"
              + userid.toUpperCase()
              + "' AND subcode="
              + subcode;
      Util.logger.info(" UPDATE DATE: " + sqlUpdate);
      statement = connection.prepareStatement(sqlUpdate);
      if (statement.execute()) {
        Util.logger.info("Update list music to send " + userid + " to dbcontent");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #26
0
  private static String[] getPhien() {
    String[] result = new String[4];
    result[0] = "";
    result[1] = "";
    result[2] = "";
    result[3] = "";

    Connection cnn = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    ResultSet rs = null;
    String query = "SELECT phien,begintime,endtime,sanpham FROM daugia_phien  where isprocess=1 ";

    try {
      cnn = dbpool.getConnectionGateway();
      statement = cnn.prepareStatement(query);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result[0] = rs.getInt(1) + "";
          result[1] = rs.getString(2);
          result[2] = rs.getString(3);
          result[3] = rs.getString(4);
          return result;
        }
      }
      return result;
    } catch (SQLException ex2) {
      Util.logger.error("GetSequence. Ex:" + ex2.toString());
      return result;
    } catch (Exception ex3) {
      Util.logger.error("GetSequece. Ex3:" + ex3.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(cnn);
    }
  }
Example #27
0
  private static String Getblacklist(String nick) {
    String result = "";
    // String musicid = "";
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    DBPool dbpool = new DBPool();

    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return result;
      }

      String sqlSelect = "SELECT blacklist FROM vtv6_nick where nick='" + nick + "'";
      Util.logger.info("SEARCH CODE  : " + sqlSelect);
      statement = connection.prepareStatement(sqlSelect);

      if (statement.execute()) {
        rs = statement.getResultSet();
        while (rs.next()) {
          result = rs.getString(1);
          Util.logger.info("Code: " + result);
          return result;
        }
      }
      return result;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return result;
    } finally {
      dbpool.cleanup(rs);
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #28
0
  private int savenickqueue(String user_id, String nick, String request_id) throws Exception {

    Connection connection = null;
    PreparedStatement statement = null;
    String sqlString = null;
    DBPool dbpool = new DBPool();
    // Util.logger.info("sendMT:" + msgObject.getUserid()+ "@TO" +
    // msgObject.getServiceid() + "@" + msgObject.getUsertext() );
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return -1;
      }
      String sqlInsert =
          "Insert into vtv6_nick (user_id,nick,request_id) values ('"
              + user_id
              + "','"
              + nick
              + "','"
              + request_id
              + "')";
      Util.logger.info("Insert:" + sqlInsert);
      statement = connection.prepareStatement(sqlInsert);
      if (statement.executeUpdate() != 1) {
        Util.logger.info("SieuRe: Insert in to daugia_winner Failed");
        return -1;
      }
      return 1;
    } catch (SQLException e) {
      Util.logger.error("SieuRe: Error:" + e.toString());
      return -1;
    } catch (Exception e) {
      Util.logger.error("SieuRe: Error:" + e.toString());
      return -1;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }
Example #29
0
  public static int executeSQL(String sql) {

    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    Connection obj = dbpool.getConnectionGateway();
    try {

      statement = obj.prepareStatement(sql);
      if (statement.executeUpdate() < 0) {
        return -1;
      }
      return 1;
    } catch (SQLException e) {

      return -1;
    } catch (Exception e) {
      return -1;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(obj);
    }
  }
Example #30
0
  private static boolean updateBlacklist(String userid, String blacklist) {

    Connection connection = null;
    PreparedStatement statement = null;
    DBPool dbpool = new DBPool();
    try {
      connection = dbpool.getConnectionGateway();
      if (connection == null) {
        Util.logger.error("Impossible to connect to DB");
        return false;
      }

      // Update cac danh sach bai hat da gui cho khach hang
      String sqlUpdate =
          "UPDATE vtv6_nick SET blacklist = '"
              + blacklist
              + "' WHERE upper(user_id)='"
              + userid.toUpperCase()
              + "' and status=1";
      Util.logger.info(" UPDATE: " + sqlUpdate);
      statement = connection.prepareStatement(sqlUpdate);
      if (statement.execute()) {
        Util.logger.info("Update vtv6_nick " + userid + " to dbcontent");
        return false;
      }
      return true;
    } catch (SQLException e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } catch (Exception e) {
      Util.logger.error(": Error:" + e.toString());
      return false;
    } finally {
      dbpool.cleanup(statement);
      dbpool.cleanup(connection);
    }
  }