Package l2p.database

Examples of l2p.database.ThreadConnection


  }

  public void restore()
  {
    final int OWNER = getOwner().getObjectId();
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY object_id DESC");
      statement.setInt(1, OWNER);
      statement.setString(2, getBaseLocation().name());
      statement.setString(3, getEquipLocation().name());
      rset = statement.executeQuery();
      L2ItemInstance item, newItem;
View Full Code Here


    L2Player player = qs.getPlayer();
    if(player == null)
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("REPLACE INTO character_quests (char_id,name,var,value) VALUES (?,?,?,?)");
      statement.setInt(1, qs.getPlayer().getObjectId());
      statement.setString(2, qs.getQuest().getName());
      statement.setString(3, var);
      statement.setString(4, value);
      statement.executeUpdate();
View Full Code Here

   *
   * @param qs : QuestState pointing out the player's quest
   */
  public static void deleteQuestInDb(QuestState qs)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? AND name=?");
      statement.setInt(1, qs.getPlayer().getObjectId());
      statement.setString(2, qs.getQuest().getName());
      statement.executeUpdate();
    }
    catch(Exception e)
View Full Code Here

   * @param qs  : object QuestState pointing out the player's quest
   * @param var : String designating the variable characterizing the quest
   */
  public static void deleteQuestVarInDb(QuestState qs, String var)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? AND name=? AND var=?");
      statement.setInt(1, qs.getPlayer().getObjectId());
      statement.setString(2, qs.getQuest().getName());
      statement.setString(3, var);
      statement.executeUpdate();
    }
View Full Code Here

   *
   * @param player : Player who is entering the world
   */
  public static void playerEnter(L2Player player)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    FiltredPreparedStatement invalidQuestData = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? and name=?");
      statement = con.prepareStatement("SELECT name,value FROM character_quests WHERE char_id=? AND var=?");
      statement.setInt(1, player.getObjectId());
      statement.setString(2, "<state>");
      rset = statement.executeQuery();
      while(rset.next())
      {
        String questId = rset.getString("name");
        String state = rset.getString("value");
        if(state.equalsIgnoreCase("Start")) // невзятый квест
        {
          invalidQuestData.setInt(1, player.getObjectId());
          invalidQuestData.setString(2, questId);
          invalidQuestData.executeUpdate();
          continue;
        }
        // Search quest associated with the ID
        Quest q = QuestManager.getQuest(questId);
        if(q == null)
        {
          if(!Config.DONTLOADQUEST)
          {
            _log.warning("Unknown quest " + questId + " for player " + player.getName());
          }
          continue;
        }
        // Create a new QuestState for the player that will be added to the player's list of quests
        new QuestState(q, player, getStateId(state));
      }
      invalidQuestData.close();
      DatabaseUtils.closeDatabaseSR(statement, rset);
      // Get list of quests owned by the player from the DB in order to add variables used in the quest.
      statement = con.prepareStatement("SELECT name,var,value FROM character_quests WHERE char_id=?");
      statement.setInt(1, player.getObjectId());
      rset = statement.executeQuery();
      while(rset.next())
      {
        String questId = rset.getString("name");
View Full Code Here

    }
    if(oldShortCut != null)
    {
      deleteShortCutFromDb(oldShortCut);
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("REPLACE INTO character_shortcuts SET char_obj_id=?,slot=?,page=?,type=?,shortcut_id=?,level=?,class_index=?");
      statement.setInt(1, player.getObjectId());
      statement.setInt(2, shortcut.slot);
      statement.setInt(3, shortcut.page);
      statement.setInt(4, shortcut.type);
      statement.setInt(5, shortcut.id);
View Full Code Here

    L2Player player = getPlayer();
    if(player == null)
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=? AND slot=? AND page=? AND class_index=?");
      statement.setInt(1, player.getObjectId());
      statement.setInt(2, shortcut.slot);
      statement.setInt(3, shortcut.page);
      statement.setInt(4, player.getActiveClassId());
      statement.execute();
View Full Code Here

    if(player == null)
    {
      return;
    }
    _shortCuts.clear();
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT char_obj_id, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE char_obj_id=? AND class_index=?");
      statement.setInt(1, player.getObjectId());
      statement.setInt(2, player.getActiveClassId());
      rset = statement.executeQuery();
      while(rset.next())
      {
View Full Code Here

  // This method loads door data from database

  private void loadDoor()
  {
    int id = 0;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT id FROM siege_door WHERE unitId = ?");
      statement.setInt(1, getId());
      rset = statement.executeQuery();
      while(rset.next())
      {
        id = rset.getInt("id");
View Full Code Here

  }
  // This method loads door upgrade data from database

  private void loadDoorUpgrade()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM siege_doorupgrade WHERE doorId IN (SELECT id FROM siege_door WHERE unitId = ?)");
      statement.setInt(1, getId());
      rset = statement.executeQuery();
      while(rset.next())
      {
        upgradeDoor(rset.getInt("doorId"), rset.getInt("hp"), false);
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.