Package l2p.database

Examples of l2p.database.ThreadConnection


    }
  }

  private void removeDoorUpgrade()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM siege_doorupgrade WHERE doorId IN (SELECT id FROM siege_door WHERE unitId=?)");
      statement.setInt(1, getId());
      statement.execute();
    }
    catch(Exception e)
    {
View Full Code Here


    }
  }

  private void saveDoorUpgrade(int doorId, int hp)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("REPLACE INTO siege_doorupgrade (doorId, hp) VALUES (?,?)");
      statement.setInt(1, doorId);
      statement.setInt(2, hp);
      statement.execute();
    }
    catch(Exception e)
View Full Code Here

    return targets.toArray(new TeleportLocation[targets.size()]);
  }

  private void loadFunctions()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rs = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM residence_functions WHERE id = ?");
      statement.setInt(1, getId());
      rs = statement.executeQuery();
      while(rs.next())
      {
        ResidenceFunction function = getFunction(rs.getInt("type"));
View Full Code Here

    if(function.isActive() && function.getLevel() == level)
    {
      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);
View Full Code Here

    return true;
  }

  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)
View Full Code Here

  }

  public synchronized void removeAugmentation()
  {
    _augmentation = null;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      if(_enchantAttributeElement != L2Item.ATTRIBUTE_NONE)
      {
        statement = con.prepareStatement("UPDATE item_attributes SET augAttributes = -1, augSkillId = -1, augSkillLevel = -1 WHERE itemId = ? LIMIT 1");
      }
      else
      {
        statement = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ? LIMIT 1");
      }
      statement.setInt(1, getObjectId());
      statement.executeUpdate();
    }
    catch(Exception e)
View Full Code Here

      _enchantAttributeFuncTemplate._value = 0; // На всякий случай
    }
    _enchantAttributeFuncTemplate = null;
    _enchantAttributeElement = L2Item.ATTRIBUTE_NONE;
    _enchantAttributeValue = 0;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?");
      statement.setInt(1, getObjectId());
      statement.executeUpdate();
    }
    catch(Exception e)
    {
View Full Code Here

    }
  }

  public synchronized void restoreAttributes()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT augAttributes,augSkillId,augSkillLevel,elemType,elemValue FROM item_attributes WHERE itemId=? LIMIT 1");
      statement.setInt(1, getObjectId());
      ResultSet rs;
      rs = statement.executeQuery();
      if(rs.next())
      {
View Full Code Here

    }
  }

  public synchronized void updateItemAttributes()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("REPLACE INTO item_attributes VALUES(?,?,?,?,?,?)");
      statement.setInt(1, getObjectId());
      if(_augmentation == null)
      {
        statement.setInt(2, -1);
        statement.setInt(3, -1);
View Full Code Here

   * @return L2ItemInstance
   */
  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);
View Full Code Here

TOP

Related Classes of l2p.database.ThreadConnection

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.