Package l2p.database

Examples of l2p.database.FiltredStatement


  }

  public void update()
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      statement.executeUpdate("UPDATE epic_boss_spawn SET respawnDate=" + _respawnDate / 1000 + ", state=" + _state.ordinal() + " WHERE bossId=" + _bossId);
      _log.info("update EpicBossState: ID:" + _bossId + ", RespawnDate:" + _respawnDate / 1000 + ", State:" + _state.toString());
    }
    catch(Exception e)
    {
      _log.warn("Exeption on update EpicBossState: ID " + _bossId + ", RespawnDate:" + _respawnDate / 1000 + ", State:" + _state.toString(), e);
View Full Code Here


  }

  private void restore()
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      rset = statement.executeQuery("SELECT bonus_name,bonus_value from bonus where obj_id='" + _owner.getObjectId() + "' and (bonus_expire_time='-1' or bonus_expire_time > " + System.currentTimeMillis() / 1000 + ")");
      while(rset.next())
      {
        String bonus_name = rset.getString("bonus_name");
        float bonus_value = rset.getFloat("bonus_value");
        Class<?> cls = getClass();
View Full Code Here

   * Помечает сообщение прочитанным.
   */
  public void markMailRead(int mailId)
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      statement.executeUpdate("UPDATE mail SET mail.unread=0 WHERE mail.messageId=" + mailId + " LIMIT 1");
    }
    catch(SQLException e)
    {
      e.printStackTrace();
    }
View Full Code Here

   * Вызывается при старте сервера, чистит базу от фигни
   */
  public void cleanupBD()
  {
    ThreadConnection con = null;
    FiltredStatement stmt = null;
    ResultSet rs = null;
    try
    {
      sendLock.lock();
      con = L2DatabaseFactory.getInstance().getConnection();
      // удаляем почту у удаленных чаров
      stmt = con.createStatement();
      stmt.executeUpdate("DELETE mail FROM mail LEFT JOIN characters ON mail.sender = characters.obj_Id WHERE characters.obj_Id IS NULL");
      DatabaseUtils.closeStatement(stmt);
      stmt = con.createStatement();
      stmt.executeUpdate("DELETE mail FROM mail LEFT JOIN characters ON mail.receiver = characters.obj_Id WHERE characters.obj_Id IS NULL");
      DatabaseUtils.closeStatement(stmt);
      // удаляем протухшие письма
      stmt = con.createStatement();
      stmt.executeUpdate("DELETE FROM mail WHERE UNIX_TIMESTAMP(expire) < UNIX_TIMESTAMP()");
      DatabaseUtils.closeStatement(stmt);
      // удаляем некорректные аттачи
      stmt = con.createStatement();
      stmt.executeUpdate("DELETE mail_attachments FROM mail_attachments LEFT JOIN items ON mail_attachments.itemId = items.object_id WHERE items.object_id IS NULL");
      DatabaseUtils.closeStatement(stmt);
      // чистим письма с потерянными аттачами
      stmt = con.createStatement();
      stmt.executeUpdate("UPDATE mail LEFT JOIN mail_attachments ON mail.messageId = mail_attachments.messageId SET price=0,attachments=0 WHERE mail_attachments.messageId IS NULL");
      DatabaseUtils.closeStatement(stmt);
      // чистим от мусора в mail_attachments, возвращая вещи владельцам
      stmt = con.createStatement();
      rs = stmt.executeQuery("SELECT itemId FROM mail_attachments LEFT JOIN mail ON mail.messageId = mail_attachments.messageId WHERE mail.messageId IS NULL");
      while(rs.next())
      {
        L2ItemInstance item = L2ItemInstance.restoreFromDb(rs.getInt("itemId"), false);
        if(item.getOwnerId() == 0)
        {
          item.removeFromDb(true);
        }
        else
        {
          returnItem(item);
        }
      }
      DatabaseUtils.closeDatabaseSR(stmt, rs);
      stmt = con.createStatement();
      stmt.executeUpdate("DELETE mail_attachments FROM mail_attachments LEFT JOIN mail ON mail.messageId = mail_attachments.messageId WHERE mail.messageId IS NULL");
      DatabaseUtils.closeStatement(stmt);
    }
    catch(SQLException e)
    {
      e.printStackTrace();
View Full Code Here

  {
    lettersByIdCache = new HashMap<Integer, Letter>();
    lettersByReceiverCache = new HashMap<Integer, GArray<Letter>>();
    lettersBySenderCache = new HashMap<Integer, GArray<Letter>>();
    ThreadConnection con = null;
    FiltredStatement stmt = null;
    FiltredStatement stmt2 = null;
    ResultSet rs = null;
    ResultSet rs2 = null;
    sendLock.lock();
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      stmt = con.createStatement();
      rs = stmt.executeQuery("SELECT m.messageId, m.topic, UNIX_TIMESTAMP(m.expire) AS lifetime, m.body, m.price, m.attachments, m.unread, m.system, m.sender, m.receiver, cs.char_name, cr.char_name FROM mail m LEFT JOIN characters cs ON ( m.sender = cs.obj_Id ) LEFT JOIN characters cr ON ( m.receiver = cr.obj_Id )");
      while(rs.next())
      {
        Letter ret = new Letter();
        ret.id = rs.getInt("m.messageId");
        ret.system = rs.getInt("m.system");
        ret.attachments = rs.getInt("m.attachments");
        ret.unread = rs.getInt("m.unread");
        ret.senderId = rs.getInt("m.sender");
        ret.receiverId = rs.getInt("m.receiver");
        ret.validtime = rs.getInt("lifetime");
        ret.senderName = rs.getString("cs.char_name");
        ret.receiverName = rs.getString("cr.char_name");
        ret.topic = rs.getString("m.topic");
        ret.body = rs.getString("m.body");
        ret.price = rs.getLong("m.price");
        if(ret.attachments > 0)
        {
          stmt2 = con.createStatement();
          rs2 = stmt2.executeQuery("SELECT itemId FROM mail_attachments WHERE messageId=" + ret.id);
          GArray<TradeItem> items = new GArray<TradeItem>(ret.attachments);
          while(rs2.next())
          {
            TradeItem ti = TradeItem.restoreFromDb(rs2.getInt("itemId"), ItemLocation.LEASE);
            if(ti != null)
View Full Code Here

  }

  private void setAllCharacterOffline()
  {
    ThreadConnection conn = null;
    FiltredStatement stmt = null;
    try
    {
      conn = L2DatabaseFactory.getInstance().getConnection();
      stmt = conn.createStatement();
      stmt.executeUpdate("UPDATE characters SET online = 0");
      stmt.executeUpdate("UPDATE characters SET accesslevel = 0 WHERE accesslevel = -1");
      _log.info("Clear characters online status and accesslevel.");
    }
    catch(SQLException e)
    {
    }
View Full Code Here

  }

  protected int[] extractUsedObjectIDTable1()
  {
    ThreadConnection con = null;
    FiltredStatement s = null;
    ResultSet rs = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      s = con.createStatement();
      String query = "SELECT " + Tasks.objTables[0][1] + ", 0 AS i FROM " + Tasks.objTables[0][0];
      for(int i = 1; i < Tasks.objTables.length; i++)
      {
        query += " UNION SELECT " + Tasks.objTables[i][1] + ", " + i + " FROM " + Tasks.objTables[i][0];
      }
      rs = s.executeQuery("SELECT COUNT(*), COUNT(DISTINCT " + Tasks.objTables[0][1] + ") FROM ( " + query + " ) AS all_ids");
      if(!rs.next())
      {
        throw new Exception("IdFactory: can't extract count ids");
      }
      if(rs.getInt(1) != rs.getInt(2))
      {
        throw new Exception("IdFactory: there are duplicates in object ids");
      }
      int[] result = new int[rs.getInt(1)];
      DatabaseUtils.closeResultSet(rs);
      _log.info("IdFactory: Extracting " + result.length + " used id's from data tables...");
      rs = s.executeQuery(query);
      int idx = 0;
      while(rs.next())
      {
        result[idx++] = rs.getInt(1);
      }
View Full Code Here

    }

    public void run()
    {
      ThreadConnection con = null;
      FiltredStatement s = null;
      ResultSet rs = null;
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        s = con.createStatement();
        rs = s.executeQuery("SELECT COUNT(*) FROM " + _objTable[0]);
        if(!rs.next())
        {
          throw new Exception("IdFactory: can't extract count ids :: " + _objTable[0]);
        }
        _objCountPut[0] = rs.getInt(1);
View Full Code Here

    }

    public void run()
    {
      ThreadConnection con = null;
      FiltredStatement s = null;
      ResultSet rs = null;
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        s = con.createStatement();
        rs = s.executeQuery("SELECT " + _objTable[1] + " FROM " + _objTable[0]);
        int idx = 0;
        while(rs.next())
        {
          _resultArray[startIdx + idx++] = rs.getInt(1);
        }
View Full Code Here

        elementData.clear();
      }
      return;
    }
    ThreadConnection con = null;
    FiltredStatement statement = null;
    ResultSet rs = null;
    int charObjId = L2ObjectsStorage.getStoredObjectId(ownerId);
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      rs = statement.executeQuery("SELECT * FROM `character_bookmarks` WHERE `char_Id`=" + charObjId + " ORDER BY `idx` LIMIT " + getCapacity());
      synchronized(this)
      {
        elementData.clear();
        while(rs.next())
        {
View Full Code Here

TOP

Related Classes of l2p.database.FiltredStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.