Package l2p.database

Examples of l2p.database.FiltredPreparedStatement


    {
      return true;
    }
    int lease = level == 0 ? 0 : getFunction(type).getLease(level);
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      if(!function.isActive())
      {
        if(count >= lease)
        {
          clan.getWarehouse().destroyItem(57, lease);
        }
        else
        {
          return false;
        }
        long time = Calendar.getInstance().getTimeInMillis() + 86400000;
        statement = con.prepareStatement("REPLACE residence_functions SET id=?, type=?, lvl=?, endTime=?");
        statement.setInt(1, getId());
        statement.setInt(2, type);
        statement.setInt(3, level);
        statement.setInt(4, (int) (time / 1000));
        statement.execute();
        function.setLvl(level);
        function.setEndTimeInMillis(time);
        function.setActive(true);
        StartAutoTaskForFunction(function);
      }
      else
      {
        if(count >= lease - getFunction(type).getLease())
        {
          if(lease > getFunction(type).getLease())
          {
            clan.getWarehouse().destroyItem(57, lease - getFunction(type).getLease());
          }
        }
        else
        {
          return false;
        }
        statement = con.prepareStatement("REPLACE residence_functions SET id=?, type=?, lvl=?");
        statement.setInt(1, getId());
        statement.setInt(2, type);
        statement.setInt(3, level);
        statement.execute();
        function.setLvl(level);
      }
    }
    catch(Exception e)
    {
View Full Code Here


  }

  public void removeFunction(int type)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM residence_functions WHERE id=? AND type=?");
      statement.setInt(1, getId());
      statement.setInt(2, type);
      statement.execute();
    }
    catch(Exception e)
    {
      _log.warning("Exception: removeFunctions(int type): " + e);
    }
View Full Code Here

   */
  public synchronized static L2ItemInstance restoreFromDb(long objectId, boolean putInStorage)
  {
    L2ItemInstance inst = null;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet item_rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM items WHERE object_id=? LIMIT 1");
      statement.setLong(1, objectId);
      item_rset = statement.executeQuery();
      if(item_rset.next())
      {
        inst = restoreFromDb(item_rset, con, putInStorage);
      }
      else
View Full Code Here

    if(_storedInDb)
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,shadow_life_time=?,item_id=?,flags=? WHERE object_id = ? LIMIT 1");
      statement.setInt(1, getOwnerId());
      statement.setLong(2, _count);
      statement.setString(3, _loc.name());
      statement.setInt(4, _loc_data);
      statement.setInt(5, getEnchantLevel());
      statement.setInt(6, _lifeTimeRemaining);
      statement.setInt(7, getItemId());
      statement.setInt(8, _customFlags);
      statement.setInt(9, getObjectId());
      statement.executeUpdate();
      _existsInDb = true;
      _storedInDb = true;
    }
    catch(Exception e)
    {
View Full Code Here

    if(isWear())
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("REPLACE INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,shadow_life_time,name,class,flags) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
      statement.setInt(1, getOwnerId());
      statement.setInt(2, _itemId);
      statement.setLong(3, _count);
      statement.setString(4, _loc.name());
      statement.setInt(5, _loc_data);
      statement.setInt(6, getEnchantLevel());
      statement.setInt(7, getObjectId());
      statement.setInt(8, _type1);
      statement.setInt(9, _type2);
      statement.setInt(10, _lifeTimeRemaining);
      statement.setString(11, getName());
      statement.setString(12, getItemClass().name());
      statement.setInt(13, _customFlags);
      statement.executeUpdate();
      _existsInDb = true;
      _storedInDb = true;
      Stat.increaseInsertItemCount();
    }
    catch(Exception e)
View Full Code Here

    if(AllowRemoveAttributes)
    {
      removeAttributes();
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM items WHERE object_id = ? LIMIT 1");
      statement.setInt(1, _objectId);
      statement.executeUpdate();
      _existsInDb = false;
      _storedInDb = false;
      Stat.increaseDeleteItemCount();
    }
    catch(Exception e)
View Full Code Here

  public void updateRentTime(boolean inDebt)
  {
    setEndTimeInMillis(System.currentTimeMillis() + 86400000);
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("UPDATE residence_functions SET endTime=?, inDebt=? WHERE type=? AND id=?");
      statement.setInt(1, (int) (getEndTimeInMillis() / 1000));
      statement.setInt(2, inDebt ? 1 : 0);
      statement.setInt(3, getType());
      statement.setInt(4, getResidenceId());
      statement.executeUpdate();
    }
    catch(Exception e)
    {
      _log.log(Level.SEVERE, "Exception: ResidenceFunction.updateRentTime(boolean inDebt): " + e.getMessage(), e);
    }
View Full Code Here

  }

  public void attach(Letter letter, L2ItemInstance... items)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement stmnt = null;
    try
    {
      sendLock.lock();
      if(items != null && items.length > 0)
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        stmnt = con.prepareStatement("INSERT INTO `mail_attachments` (`messageId`, `itemId`) VALUES (?,?)");
        letter.attached = new GArray<TradeItem>(items.length);
        for(int i = 0; i < items.length; i++)
        {
          L2ItemInstance item = items[i];
          item.setOwnerId(letter.senderId);
          item.setLocation(ItemLocation.LEASE);
          item.updateDatabase(true, false);
          letter.attached.add(new TradeItem(item));
          stmnt.setInt(1, letter.id);
          stmnt.setInt(2, item.getObjectId());
          stmnt.executeUpdate();
        }
        letter.attachments = letter.attached.size();
      }
    }
    catch(Exception e)
View Full Code Here

   * Вовзращает список прикрепленных вещей.
   */
  public GArray<L2ItemInstance> listAttachedItems(int mailId)
  {
    GArray<L2ItemInstance> ret = new GArray<L2ItemInstance>(8);
    FiltredPreparedStatement statement = null;
    ResultSet rs = null;
    ThreadConnection con = null;
    sendLock.lock();
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT itemId FROM mail_attachments WHERE messageId = ?");
      statement.setInt(1, mailId);
      rs = statement.executeQuery();
      while(rs.next())
      {
        ret.add(L2ItemInstance.restoreFromDb(rs.getInt("itemId"), false));
      }
    }
View Full Code Here

   * Удаляет письмо. Перед этим следует вернуть приложенные вещи.
   */
  public void deleteLetter(int... mailIds)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement stmnt = null;
    sendLock.lock();
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      stmnt = con.prepareStatement("DELETE FROM mail WHERE messageId=? LIMIT 1");
      GArray<Letter> removed = new GArray<Letter>(mailIds.length);
      for(int id : mailIds)
      {
        Letter letter = lettersByIdCache.remove(id);
        if(letter == null)
        {
          continue;
        }
        GArray<Letter> cached = lettersBySenderCache.get(letter.senderId);
        if(cached != null)
        {
          cached.remove(letter);
          if(cached.isEmpty())
          {
            lettersBySenderCache.remove(letter.senderId);
          }
        }
        cached = lettersByReceiverCache.get(letter.receiverId);
        if(cached != null)
        {
          cached.remove(letter);
          if(cached.isEmpty())
          {
            lettersByReceiverCache.remove(letter.receiverId);
          }
        }
        removed.add(letter);
        stmnt.setInt(1, id);
        stmnt.executeUpdate();
      }
      DatabaseUtils.closeStatement(stmnt);
      stmnt = con.prepareStatement("DELETE FROM mail_attachments WHERE messageId=? LIMIT ?");
      for(Letter letter : removed)
      {
        stmnt.setInt(1, letter.id);
        stmnt.setInt(2, letter.attachments);
        stmnt.executeUpdate();
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of l2p.database.FiltredPreparedStatement

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.