Package l2p.database

Examples of l2p.database.FiltredPreparedStatement


    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();
    }
    catch(Exception e)
    {
      _log.log(Level.WARNING, "could not insert char quest:", e);
    }
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)
    {
      _log.log(Level.WARNING, "could not delete char quest:", e);
    }
View Full Code Here

   * @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();
    }
    catch(Exception e)
    {
      _log.log(Level.WARNING, "could not delete char quest:", e);
    }
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();
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);
      statement.setInt(6, shortcut.level);
      statement.setInt(7, player.getActiveClassId());
      statement.execute();
    }
    catch(Exception e)
    {
      _log.log(Level.WARNING, "could not store shortcuts:", e);
    }
View Full Code Here

    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();
    }
    catch(Exception e)
    {
      _log.log(Level.WARNING, "could not delete shortcuts:", e);
    }
View Full Code Here

    {
      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())
      {
        int slot = rset.getInt("slot");
        int page = rset.getInt("page");
        int type = rset.getInt("type");
View Full Code Here

   * Для письма обязательно должны быть определены поля validtime (unixtime просрочки), topic и body. Остальные поля можно опустить, если установить флаг system.
   */
  public void sendLetter(Letter letter, int[] attachments, long[] attItemsQ, L2Player sender)
  {
    ThreadConnection con = null;
    FiltredPreparedStatement stmnt = null;
    ResultSet rs = null;
    try
    {
      sendLock.lock();
      con = L2DatabaseFactory.getInstance().getConnection();
      stmnt = con.prepareStatement("INSERT INTO `mail` (`sender`, `receiver`, `topic`, `body`, `attachments`, `price`, `expire`, `system`) VALUES (?,?,?,?,?,?,FROM_UNIXTIME(?),?)");
      stmnt.setInt(1, letter.senderId);
      stmnt.setInt(2, letter.receiverId);
      stmnt.setString(3, letter.topic);
      stmnt.setString(4, letter.body);
      stmnt.setInt(5, attachments == null ? 0 : attachments.length);
      stmnt.setLong(6, letter.price);
      stmnt.setLong(7, letter.validtime);
      stmnt.setInt(8, letter.system);
      stmnt.executeUpdate();
      DatabaseUtils.closeStatement(stmnt);
      stmnt = con.prepareStatement("SELECT LAST_INSERT_ID()");
      rs = stmnt.executeQuery();
      if(rs.next())
      {
        letter.id = rs.getInt(1);
      }
      if(letter.id == 0) // письмо не добавилось в базу?
View Full Code Here

  }

  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"));
        function.setLvl(rs.getInt("lvl"));
        function.setEndTimeInMillis(rs.getInt("endTime") * 1000L);
 
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);
        statement.setInt(4, -1);
      }
      else
      {
        statement.setInt(2, _augmentation.getAugmentationId());
        if(_augmentation.getSkill() == null)
        {
          statement.setInt(3, 0);
          statement.setInt(4, 0);
        }
        else
        {
          statement.setInt(3, _augmentation.getSkill().getId());
          statement.setInt(4, _augmentation.getSkill().getLevel());
        }
      }
      statement.setByte(5, _enchantAttributeElement);
      statement.setInt(6, _enchantAttributeValue);
      statement.executeUpdate();
    }
    catch(Exception e)
    {
      _log.info("Could not remove elemental enchant for item: " + getObjectId() + " from DB:");
      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.