Package l2p.database

Examples of l2p.database.ThreadConnection


                }
        }

        private static void DeleteAccount(String account) throws SQLException
        {
                ThreadConnection con = null;
                FiltredPreparedStatement statement = null;
                FiltredPreparedStatement subStatement = null;
                ResultSet rset = null, subRset = null;
                try
                {
                        con = L2DatabaseFactory.getInstance().getConnection();
                        // Check Account Exist
                        statement = con.prepareStatement("SELECT COUNT(*) FROM accounts WHERE login=?;");
                        statement.setString(1, account);
                        rset = statement.executeQuery();
                        if(rset.getInt(1) == 0)
                        {
                                System.out.println("Account \"" + account + "\" Not Exist\n");
                                return;
                        }
                        // Account exist
                        DatabaseUtils.closeDatabaseSR(statement, rset);
                        // Get Accounts ID
                        statement = con.prepareStatement("SELECT obj_Id, char_name, clanid FROM characters WHERE account_name=?;");
                        statement.setEscapeProcessing(true);
                        statement.setString(1, account);
                        rset = statement.executeQuery();
                        while(rset.next())
                        {
                                System.out.println("Deleting character \"" + rset.getString("char_name") + "\"\n");
                                // Check If clan leader Remove Clan and remove all from it
                                subStatement = con.prepareStatement("SELECT COUNT(*) FROM clan_data WHERE leader_id=?;");
                                subStatement.setString(1, rset.getString("clanid"));
                                subRset = subStatement.executeQuery();
                                boolean isClanLeader = false;
                                if(subRset.next() && subRset.getInt(1) > 0)
                                {
                                        isClanLeader = true;
                                }
                                DatabaseUtils.closeDatabaseSR(subStatement, subRset);
                                if(isClanLeader)
                                {
                                        // Clan Leader
                                        // Get Clan Name
                                        subStatement = con.prepareStatement("SELECT clan_name FROM clan_data WHERE leader_id=?;");
                                        subStatement.setString(1, rset.getString("clanid"));
                                        subRset = subStatement.executeQuery();
                                        String clanName = null;
                                        if(subRset.next())
                                        {
                                                clanName = subRset.getString("clan_name");
                                        }
                                        System.out.println("Deleting clan \"" + clanName + "\"\n");
                                        DatabaseUtils.closeDatabaseSR(subStatement, subRset);
                                        // Delete Clan Wars
                                        subStatement = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? OR clan2=?;");
                                        subStatement.setEscapeProcessing(true);
                                        subStatement.setString(1, clanName);
                                        subStatement.setString(2, clanName);
                                        subStatement.executeUpdate();
                                        DatabaseUtils.closeStatement(subStatement);
                                        // Remove All From clan
                                        subStatement = con.prepareStatement("UPDATE characters SET clanid=0 WHERE clanid=?;");
                                        subStatement.setString(1, rset.getString("clanid"));
                                        subStatement.executeUpdate();
                                        DatabaseUtils.closeStatement(subStatement);
                                        // Delete Clan
                                        subStatement = con.prepareStatement("DELETE FROM clan_data WHERE clan_id=?;");
                                        subStatement.setString(1, rset.getString("clanid"));
                                        subStatement.executeUpdate();
                                        DatabaseUtils.closeStatement(subStatement);
                                }
                                // skills
                                subStatement = con.prepareStatement("DELETE FROM character_skills WHERE char_obj_id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // shortcuts
                                subStatement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // items
                                subStatement = con.prepareStatement("DELETE FROM items WHERE owner_id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // recipebook
                                subStatement = con.prepareStatement("DELETE FROM character_recipebook WHERE char_id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // quests
                                subStatement = con.prepareStatement("DELETE FROM character_quests WHERE char_id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // macroses
                                subStatement = con.prepareStatement("DELETE FROM character_macroses WHERE char_obj_id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // friends
                                subStatement = con.prepareStatement("DELETE FROM character_friends WHERE char_id=? or friend_id = ?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.setString(2, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // boxaccess
                                subStatement = con.prepareStatement("DELETE FROM boxaccess WHERE charname=?;");
                                subStatement.setString(1, rset.getString("char_name"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                                // characters
                                subStatement = con.prepareStatement("DELETE FROM characters WHERE obj_Id=?;");
                                subStatement.setString(1, rset.getString("obj_Id"));
                                subStatement.executeUpdate();
                                DatabaseUtils.closeStatement(subStatement);
                        }
                        DatabaseUtils.closeDatabaseSR(statement, rset);
                        // Delete Account
                        statement = con.prepareStatement("DELETE FROM accounts WHERE login=?;");
                        statement.setEscapeProcessing(true);
                        statement.setString(1, account);
                        statement.executeUpdate();
                        System.out.println("Account \"" + account + "\" Deleted\n\n");
                }
View Full Code Here


    {0x25}, {0x10}, {0x11}, {0x1e}, {0x0c}, {0x1b}, {0x28}, {0x0e}, {0x1c}, {0x29}, {0x0d},
    {0x06}, {0x22}, {0x21}, {0x2b}, {0x37}, {0x39}};

  private void cleanTempVars()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement st = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      st = con.prepareStatement("DELETE FROM character_quests WHERE name=? AND (var='spawned' OR var='kills' OR var='Archon' OR var LIKE 'Mob_%')");
      st.setString(1, getName());
      st.executeUpdate();
    }
    catch(Exception e)
    {
View Full Code Here

  private static GArray<L2Spawn> _Room2InsideSpawnList = new GArray<L2Spawn>();
  private static GArray<L2Spawn> _Room2OutsideSpawnList = new GArray<L2Spawn>();

  public static void fill()
  {
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("SELECT * FROM lastimperialtomb_spawnlist");
      rset = statement.executeQuery();
      int npcTemplateId;
      L2Spawn spawnDat;
      L2NpcTemplate npcTemplate;
      while(rset.next())
View Full Code Here

    return sb.toString();
  }

  private static String addStatisticPvP()
  {
    ThreadConnection tc = null;
    FiltredPreparedStatement fps = null;
    ResultSet rs = null;
    try
    {
      tc = L2DatabaseFactory.getInstance().getConnection();
      fps = tc.prepareStatement("SELECT * FROM characters ORDER BY pvpkills DESC LIMIT 20;");
      rs = fps.executeQuery();
      StringBuilder sb = new StringBuilder();
      sb.append("<table width=650>");
      sb.append("<tr><td><center>ТОП 20 PVP");
      sb.append("<img src=L2UI.SquareWhite width=450 height=1>");
View Full Code Here

    return null;
  }

  private static String addStatisticPK()
  {
    ThreadConnection tc = null;
    FiltredPreparedStatement fps = null;
    ResultSet rs = null;
    try
    {
      tc = L2DatabaseFactory.getInstance().getConnection();
      fps = tc.prepareStatement("SELECT * FROM characters ORDER BY pkkills DESC LIMIT 20;");
      rs = fps.executeQuery();
      StringBuilder sb = new StringBuilder();
      sb.append("<table width=650>");
      sb.append("<tr><td><center>ТОП 20 PK");
      sb.append("<img src=L2UI.SquareWhite width=450 height=1>");
View Full Code Here

    return null;
  }

  private static String addStatisticNoble()
  {
    ThreadConnection tc = null;
    FiltredPreparedStatement fps = null;
    ResultSet rs = null;
    try
    {
      tc = L2DatabaseFactory.getInstance().getConnection();
      fps = tc.prepareStatement("SELECT cha.char_name, cha.sex, cha.onlinetime, cha.pkkills, cha.pvpkills, cha.online FROM characters cha, olympiad_nobles oly WHERE cha.obj_Id = oly.char_id ORDER BY cha.pvpkills DESC LIMIT 20");
      rs = fps.executeQuery();
      StringBuilder sb = new StringBuilder();
      sb.append("<table width=650>");
      sb.append("<tr><td><center>ТОП 20 Дворян");
      sb.append("<img src=L2UI.SquareWhite width=450 height=1>");
View Full Code Here

  }

  private static String addStatisticCastle()
  {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    ThreadConnection tc = null;
    FiltredPreparedStatement fps = null;
    ResultSet rs = null;
    try
    {
      tc = L2DatabaseFactory.getInstance().getConnection();
      fps = tc.prepareStatement("SELECT * FROM castle ORDER BY id DESC LIMIT 10;");
      rs = fps.executeQuery();
      StringBuilder sb = new StringBuilder();
      sb.append("<table width=650>");
      sb.append("<tr><td><center>Статистика Замков");
      sb.append("<img src=L2UI.SquareWhite width=450 height=1>");
View Full Code Here

    return null;
  }

  private static String addStatisticClan()
  {
    ThreadConnection tc = null;
    FiltredPreparedStatement fps = null;
    ResultSet rs = null;
    try
    {
      tc = L2DatabaseFactory.getInstance().getConnection();
      fps = tc.prepareStatement("SELECT * FROM clan_data c WHERE c.clan_level > 0 ORDER BY c.clan_level DESC LIMIT 10;");
      rs = fps.executeQuery();
      StringBuilder sb = new StringBuilder();
      sb.append("<table width=650>");
      sb.append("<tr><td><center>Топ 10 Кланов");
      sb.append("<img src=L2UI.SquareWhite width=450 height=1>");
View Full Code Here

    return null;
  }

  private static String addStatisticFame()
  {
    ThreadConnection tc = null;
    FiltredPreparedStatement fps = null;
    ResultSet rs = null;
    try
    {
      tc = L2DatabaseFactory.getInstance().getConnection();
      fps = tc.prepareStatement("SELECT * FROM characters ORDER BY fame DESC LIMIT 20;");
      rs = fps.executeQuery();
      StringBuilder sb = new StringBuilder();
      sb.append("<table width=650>");
      sb.append("<tr><td><center>ТОП 20 Славы");
      sb.append("<img src=L2UI.SquareWhite width=450 height=1>");
View Full Code Here

    if(wordList.length != 2)
    {
      return false;
    }
    String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
    ThreadConnection con = null;
    FiltredPreparedStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement(cmd);
      statement.setString(1, wordList[1]);
      statement.execute();
      DatabaseUtils.closeStatement(statement);
      statement = con.prepareStatement("SELECT obj_id FROM characters where char_name=?");
      statement.setString(1, wordList[1]);
      rset = statement.executeQuery();
      int objId = 0;
      if(rset.next())
      {
        objId = rset.getInt(1);
      }
      DatabaseUtils.closeDatabaseSR(statement, rset);
      if(objId == 0)
      {
        return false;
      }
      // con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=?");
      statement.setInt(1, objId);
      statement.execute();
      DatabaseUtils.closeStatement(statement);
      // con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement("UPDATE items SET loc='INVENTORY' WHERE owner_id=? AND loc!='WAREHOUSE'");
      statement.setInt(1, objId);
      statement.execute();
    }
    catch(Exception e)
    {
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.