Package l2p.database

Examples of l2p.database.FiltredPreparedStatement


  public static String getPlayerNameByObjId(int oid)
  {
    String pName = null;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT `char_name` FROM `characters` WHERE `obj_Id`=\"" + oid + "\" LIMIT 1");
      rset = statement.executeQuery();
      if(rset.next())
      {
        pName = rset.getString(1);
      }
    }
View Full Code Here


      _logChat.log(record);
    }
    if(Config.LOG_CHAT_DB != null && !Config.LOG_CHAT_DB.isEmpty())
    {
      ThreadConnection con = null;
      FiltredPreparedStatement statement = null;
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("INSERT DELAYED INTO " + Config.LOG_CHAT_DB + " (`type`,`text`,`from`,`to`) VALUES(?,?,?,?);");
        statement.setString(1, type.trim());
        statement.setString(2, text);
        statement.setString(3, from);
        statement.setString(4, to != null ? to : "");
        statement.execute();
      }
      catch(Exception e)
      {
        _log.warning("fail to sql log chat[" + type + "|" + text + "|" + from + "|" + to + "]: " + e);
        e.printStackTrace();
View Full Code Here

  public static void SqlLog(L2Character activeObject, L2Character target, Integer log_id, L2ItemInstance Item, String etc_str1, String etc_str2, String etc_str3, Integer etc_num1, Integer etc_num2, Integer etc_num3, Integer etc_num4, Integer etc_num5, Integer etc_num6, Integer etc_num7, Integer etc_num8, Long etc_num9, Long etc_num10)
  {
    if(Config.SQL_LOG)
    {
      ThreadConnection con = null;
      FiltredPreparedStatement statement = null;
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("INSERT INTO game_log (serv_id, act_time, log_id, actor, actor_type, target, target_type, location_x, location_y, location_z, etc_str1, etc_str2, etc_str3, etc_num1, etc_num2, etc_num3, etc_num4, etc_num5, etc_num6, etc_num7, etc_num8, etc_num9, etc_num10, STR_actor, STR_actor_account, STR_target, STR_target_account, item_id) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
        statement.setInt(1, 0); //serv_id
        statement.setLong(2, System.currentTimeMillis() / 1000); //act_time
        statement.setInt(3, log_id); //log_id
        if(activeObject != null)
        {
          statement.setInt(4, activeObject.isNpc() ? activeObject.getNpcId() : activeObject.getObjectId());
          statement.setString(5, activeObject.getClass().getName());
        }
        else
        {
          statement.setInt(4, 0);
          statement.setString(5, "");
        }
        if(target != null && activeObject != null)
        {
          statement.setInt(6, target.isNpc() ? target.getNpcId() : target.getObjectId());
          statement.setString(7, target.getClass().getName());
          statement.setInt(8, activeObject.getX()); //location_x,
          statement.setInt(9, activeObject.getY()); //location_y,
          statement.setInt(10, activeObject.getZ()); //location_z,
        }
        else
        {
          statement.setInt(6, 0);
          statement.setString(7, "");
          statement.setInt(8, 0);
          statement.setInt(9, 0);
          statement.setInt(10, 0);
        }
        statement.setString(11, etc_str1); //etc_str1,
        statement.setString(12, etc_str2); //etc_str2
        statement.setString(13, etc_str3); //etc_str3,
        statement.setInt(14, etc_num1); //etc_num1,
        statement.setInt(15, etc_num2); //etc_num2,
        statement.setInt(16, etc_num3); //etc_num3,
        statement.setInt(17, etc_num4); //etc_num4,
        statement.setInt(18, etc_num5); //etc_num5,
        statement.setInt(19, etc_num6); //etc_num6,
        statement.setInt(20, etc_num7); //etc_num7,
        statement.setInt(21, etc_num8);
        statement.setLong(22, etc_num9);
        statement.setLong(23, etc_num10);
        if(activeObject != null)
        {
          statement.setString(24, activeObject.getName()); //STR_actor,
          statement.setString(25, activeObject.isPlayer() ? ((L2Player) activeObject).getAccountName() : ""); //STR_actor_account,
        }
        else
        {
          statement.setString(24, "");
          statement.setString(25, "");
        }
        if(target != null)
        {
          statement.setString(26, target.getName()); //STR_target,
          statement.setString(27, target.isPlayer() ? ((L2Player) target).getAccountName() : ""); //STR_target_account
        }
        else
        {
          statement.setString(26, "");
          statement.setString(27, "");
        }
        statement.setInt(28, Item != null ? Item.getObjectId() : 0); //item_id
        statement.executeUpdate();
      }
      catch(Exception e)
      {
        _log.log(Level.SEVERE, "Could not insert log into DB:", e);
      }
View Full Code Here

  public static void LogPetition(L2Player fromChar, Integer Petition_type, String Petition_text)
  {
    if(Config.SQL_LOG)
    {
      ThreadConnection con = null;
      FiltredPreparedStatement statement = null;
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("INSERT INTO petitions (serv_id, act_time, petition_type, actor, location_x, location_y, location_z, petition_text, STR_actor, STR_actor_account) VALUES (?,?,?,?,?,?,?,?,?,?);");
        statement.setInt(1, 0); //serv_id
        statement.setLong(2, System.currentTimeMillis() / 1000); //act_time
        statement.setInt(3, Petition_type); //log_id
        statement.setInt(4, fromChar.getObjectId());
        statement.setInt(5, fromChar.getX()); //location_x,
        statement.setInt(6, fromChar.getY()); //location_y,
        statement.setInt(7, fromChar.getZ()); //location_z,
        statement.setString(8, Petition_text);
        statement.setString(9, fromChar.getName()); //STR_actor,
        statement.setString(10, fromChar.getAccountName()); //STR_actor_account,
        statement.executeUpdate();
      }
      catch(Exception e)
      {
        _log.log(Level.SEVERE, "Could not insert petition into DB:", e);
      }
View Full Code Here

    if(!Config.SQL_LOG)
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("INSERT INTO loginserv_log (act_time, log_id, etc_str1, etc_str2, etc_str3, etc_num1, etc_num2) " + "VALUES (?,?,?,?,?,?,?);");
      statement.setLong(1, System.currentTimeMillis() / 1000); //act_time
      statement.setInt(2, log_id); //log_id
      statement.setString(3, etc_str1); //etc_str1,
      statement.setString(4, etc_str2); //etc_str2
      statement.setString(5, etc_str3); //etc_str3,
      statement.setInt(6, etc_num1); //etc_num1,
      statement.setInt(7, etc_num2); //etc_num2,
      statement.executeUpdate();
    }
    catch(Exception e)
    {
      _log.log(Level.SEVERE, "Could not insert log into DB:", e);
    }
View Full Code Here

  }

  public void load()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM epic_boss_spawn WHERE bossId = ? LIMIT 1");
      statement.setInt(1, _bossId);
      rset = statement.executeQuery();
      if(rset.next())
      {
        _respawnDate = rset.getLong("respawnDate") * 1000L;
        if(_respawnDate - System.currentTimeMillis() <= 0)
        {
View Full Code Here

  }

  public void save()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("REPLACE INTO epic_boss_spawn (bossId,respawnDate,state) VALUES(?,?,?)");
      statement.setInt(1, _bossId);
      statement.setInt(2, (int) (_respawnDate / 1000));
      statement.setInt(3, _state.ordinal());
      statement.execute();
      statement.close();
    }
    catch(Exception e)
    {
      _log.error(e.getMessage(), e);
    }
View Full Code Here

  private boolean HaveBonus(String type)
  {
    L2Player player = (L2Player) getSelf();
    ResultSet rs = null;
    ThreadConnection con = null;
    FiltredPreparedStatement offline = null;
    Calendar end_;
    end_ = Calendar.getInstance();
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      offline = con.prepareStatement("SELECT bonus_expire_time FROM bonus WHERE obj_id LIKE ? AND bonus_name = ?");
      offline.setInt(1, player.getObjectId());
      offline.setString(2, type);
      rs = offline.executeQuery();
      if(rs.next())
      {
        end_.setTimeInMillis(rs.getLong(1) * 1000L);
        show(new CustomMessage("scripts.services.Bonus.bonus.alreadychar", player).addString(String.valueOf(end_.get(Calendar.DAY_OF_MONTH)) + "." + String.valueOf(end_.get(Calendar.MONTH) + 1) + "." + String.valueOf(end_.get(Calendar.YEAR))), player);
        return true;
View Full Code Here

    if(HaveBonus(bonus_class))
    {
      return;
    }
    ThreadConnection con = null;
    FiltredPreparedStatement offline = null;
    Calendar bonus_expire = Calendar.getInstance();
    if(getItemCount(player, Config.SERVICES_RATE_SPECIAL_ITEM_ID) < Config.SERVICES_RATE_SPECIAL_ITEM_COUNT)
    {
      if(Config.SERVICES_RATE_SPECIAL_ITEM_ID == 57)
      {
        player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      }
      else
      {
        player.sendPacket(Msg.INCORRECT_ITEM_COUNT);
      }
      return;
    }
    bonus_expire.add(Calendar.DAY_OF_MONTH, Config.SERVICES_RATE_SPECIAL_DAYS);
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      offline = con.prepareStatement("INSERT INTO bonus(obj_id, bonus_name, bonus_value, bonus_expire_time) VALUES (?,?,?,?)");
      offline.setInt(1, player.getObjectId());
      offline.setString(2, bonus_class);
      offline.setInt(3, Config.SERVICES_RATE_SPECIAL_RATE);
      offline.setLong(4, bonus_expire.getTimeInMillis() / 1000);
      offline.executeUpdate();
    }
    catch(Exception e)
    {
      e.printStackTrace();
      show(new CustomMessage("common.Error", player), player);
View Full Code Here

    }
    // check if target has player on friendlist
    boolean FoundOnFriendList = false;
    int objectId;
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id=?");
      statement.setInt(1, ptarget.getObjectId());
      rset = statement.executeQuery();
      while(rset.next())
      {
        objectId = rset.getInt("friend_id");
        if(objectId == activeChar.getObjectId())
        {
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.