Pārlūkot izejas kodu

Replacing old L2DatabaseFactory with new ConnectionFactory

Reviewed all database access.
Zoey76 9 gadi atpakaļ
vecāks
revīzija
dc3ef6bf31
100 mainītis faili ar 1314 papildinājumiem un 1588 dzēšanām
  1. 0 274
      L2J_Server/java/com/l2jserver/L2DatabaseFactory.java
  2. 2 2
      L2J_Server/java/com/l2jserver/gameserver/GameServer.java
  3. 2 2
      L2J_Server/java/com/l2jserver/gameserver/LoginServerThread.java
  4. 6 6
      L2J_Server/java/com/l2jserver/gameserver/SevenSigns.java
  5. 5 5
      L2J_Server/java/com/l2jserver/gameserver/SevenSignsFestival.java
  6. 2 2
      L2J_Server/java/com/l2jserver/gameserver/Shutdown.java
  7. 5 5
      L2J_Server/java/com/l2jserver/gameserver/communitybbs/BB/Forum.java
  8. 5 5
      L2J_Server/java/com/l2jserver/gameserver/communitybbs/BB/Post.java
  9. 3 3
      L2J_Server/java/com/l2jserver/gameserver/communitybbs/BB/Topic.java
  10. 2 2
      L2J_Server/java/com/l2jserver/gameserver/communitybbs/Manager/ForumsBBSManager.java
  11. 2 2
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/AnnouncementsTable.java
  12. 6 6
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/CharNameTable.java
  13. 6 6
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/CharSummonTable.java
  14. 6 6
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/ClanTable.java
  15. 12 14
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/CrestTable.java
  16. 3 3
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/NpcBufferTable.java
  17. 3 3
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/OfflineTradersTable.java
  18. 2 2
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/PetNameTable.java
  19. 2 2
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/SummonSkillsTable.java
  20. 3 3
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/TeleportLocationTable.java
  21. 2 2
      L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/TerritoryTable.java
  22. 2 2
      L2J_Server/java/com/l2jserver/gameserver/data/xml/impl/BuyListData.java
  23. 3 3
      L2J_Server/java/com/l2jserver/gameserver/datatables/BotReportTable.java
  24. 2 2
      L2J_Server/java/com/l2jserver/gameserver/datatables/ItemTable.java
  25. 4 4
      L2J_Server/java/com/l2jserver/gameserver/datatables/SpawnTable.java
  26. 2 2
      L2J_Server/java/com/l2jserver/gameserver/idfactory/CompactionIDFactory.java
  27. 6 6
      L2J_Server/java/com/l2jserver/gameserver/idfactory/IdFactory.java
  28. 2 2
      L2J_Server/java/com/l2jserver/gameserver/idfactory/StackIDFactory.java
  29. 4 4
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/AirShipManager.java
  30. 3 3
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/AuctionManager.java
  31. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/CHSiegeManager.java
  32. 3 3
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/CastleManager.java
  33. 8 8
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/CastleManorManager.java
  34. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/ClanHallManager.java
  35. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/CoupleManager.java
  36. 47 49
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/CursedWeaponsManager.java
  37. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/DimensionalRiftManager.java
  38. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/FortManager.java
  39. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/FortSiegeGuardManager.java
  40. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/FortSiegeManager.java
  41. 6 6
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/FourSepulchersManager.java
  42. 3 3
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/GlobalVariablesManager.java
  43. 7 7
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/GrandBossManager.java
  44. 4 4
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/InstanceManager.java
  45. 13 13
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/ItemAuctionManager.java
  46. 17 17
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/ItemsOnGroundManager.java
  47. 8 8
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/MailManager.java
  48. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/MercTicketManager.java
  49. 2 2
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/PunishmentManager.java
  50. 6 6
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/RaidBossPointsManager.java
  51. 39 37
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/RaidBossSpawnManager.java
  52. 15 15
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/SiegeGuardManager.java
  53. 7 7
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/SiegeManager.java
  54. 6 6
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/TerritoryWarManager.java
  55. 41 41
      L2J_Server/java/com/l2jserver/gameserver/instancemanager/games/Lottery.java
  56. 2 2
      L2J_Server/java/com/l2jserver/gameserver/model/AutoSpawnHandler.java
  57. 31 31
      L2J_Server/java/com/l2jserver/gameserver/model/BlockList.java
  58. 3 3
      L2J_Server/java/com/l2jserver/gameserver/model/CursedWeapon.java
  59. 29 29
      L2J_Server/java/com/l2jserver/gameserver/model/L2Clan.java
  60. 4 4
      L2J_Server/java/com/l2jserver/gameserver/model/L2ClanMember.java
  61. 17 17
      L2J_Server/java/com/l2jserver/gameserver/model/L2ContactList.java
  62. 4 4
      L2J_Server/java/com/l2jserver/gameserver/model/MacroList.java
  63. 19 19
      L2J_Server/java/com/l2jserver/gameserver/model/ShortCuts.java
  64. 12 11
      L2J_Server/java/com/l2jserver/gameserver/model/UIKeysSettings.java
  65. 303 305
      L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  66. 25 25
      L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PetInstance.java
  67. 18 18
      L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2ServitorInstance.java
  68. 19 19
      L2J_Server/java/com/l2jserver/gameserver/model/announce/Announcement.java
  69. 21 21
      L2J_Server/java/com/l2jserver/gameserver/model/announce/AutoAnnouncement.java
  70. 12 12
      L2J_Server/java/com/l2jserver/gameserver/model/buylist/Product.java
  71. 62 62
      L2J_Server/java/com/l2jserver/gameserver/model/entity/Auction.java
  72. 15 15
      L2J_Server/java/com/l2jserver/gameserver/model/entity/Castle.java
  73. 4 4
      L2J_Server/java/com/l2jserver/gameserver/model/entity/ClanHall.java
  74. 5 5
      L2J_Server/java/com/l2jserver/gameserver/model/entity/Couple.java
  75. 15 15
      L2J_Server/java/com/l2jserver/gameserver/model/entity/Fort.java
  76. 14 14
      L2J_Server/java/com/l2jserver/gameserver/model/entity/FortSiege.java
  77. 34 34
      L2J_Server/java/com/l2jserver/gameserver/model/entity/Hero.java
  78. 36 36
      L2J_Server/java/com/l2jserver/gameserver/model/entity/Siege.java
  79. 8 8
      L2J_Server/java/com/l2jserver/gameserver/model/entity/clanhall/AuctionableHall.java
  80. 13 13
      L2J_Server/java/com/l2jserver/gameserver/model/entity/clanhall/ClanHallSiegeEngine.java
  81. 7 7
      L2J_Server/java/com/l2jserver/gameserver/model/entity/clanhall/SiegableHall.java
  82. 16 15
      L2J_Server/java/com/l2jserver/gameserver/model/itemauction/ItemAuction.java
  83. 5 4
      L2J_Server/java/com/l2jserver/gameserver/model/itemauction/ItemAuctionInstance.java
  84. 7 7
      L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java
  85. 6 6
      L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/ItemContainer.java
  86. 7 7
      L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/Mail.java
  87. 5 5
      L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/PcInventory.java
  88. 9 9
      L2J_Server/java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java
  89. 65 64
      L2J_Server/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java
  90. 13 13
      L2J_Server/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameNormal.java
  91. 16 16
      L2J_Server/java/com/l2jserver/gameserver/model/punishment/PunishmentTask.java
  92. 44 44
      L2J_Server/java/com/l2jserver/gameserver/model/quest/Quest.java
  93. 13 13
      L2J_Server/java/com/l2jserver/gameserver/model/quest/QuestState.java
  94. 3 3
      L2J_Server/java/com/l2jserver/gameserver/model/variables/AccountVariables.java
  95. 6 6
      L2J_Server/java/com/l2jserver/gameserver/model/variables/PlayerVariables.java
  96. 4 4
      L2J_Server/java/com/l2jserver/gameserver/network/L2GameClient.java
  97. 2 2
      L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestAnswerFriendInvite.java
  98. 2 2
      L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestDestroyItem.java
  99. 2 2
      L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestFriendDel.java
  100. 2 2
      L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestPetitionFeedback.java

+ 0 - 274
L2J_Server/java/com/l2jserver/L2DatabaseFactory.java

@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2004-2015 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.l2jserver.gameserver.ThreadPoolManager;
-import com.mchange.v2.c3p0.ComboPooledDataSource;
-
-/**
- * This class manages the database connections.
- */
-public class L2DatabaseFactory
-{
-	private static final Logger _log = Logger.getLogger(L2DatabaseFactory.class.getName());
-	
-	private static L2DatabaseFactory _instance;
-	private static volatile ScheduledExecutorService _executor;
-	private ComboPooledDataSource _source;
-	
-	/**
-	 * Instantiates a new l2 database factory.
-	 * @throws SQLException the SQL exception
-	 */
-	public L2DatabaseFactory() throws SQLException
-	{
-		try
-		{
-			if (Config.DATABASE_MAX_CONNECTIONS < 2)
-			{
-				Config.DATABASE_MAX_CONNECTIONS = 2;
-				_log.warning("A minimum of " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
-			}
-			
-			_source = new ComboPooledDataSource();
-			_source.setAutoCommitOnClose(true);
-			
-			_source.setInitialPoolSize(10);
-			_source.setMinPoolSize(10);
-			_source.setMaxPoolSize(Math.max(10, Config.DATABASE_MAX_CONNECTIONS));
-			
-			_source.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
-			_source.setAcquireRetryDelay(500); // 500 milliseconds wait before try to acquire connection again
-			_source.setCheckoutTimeout(0); // 0 = wait indefinitely for new connection
-			// if pool is exhausted
-			_source.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time
-			// cause there is a "long" delay on acquire connection
-			// so taking more than one connection at once will make connection pooling
-			// more effective.
-			
-			// this "connection_test_table" is automatically created if not already there
-			_source.setAutomaticTestTable("connection_test_table");
-			_source.setTestConnectionOnCheckin(false);
-			
-			// testing OnCheckin used with IdleConnectionTestPeriod is faster than testing on checkout
-			
-			_source.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
-			_source.setMaxIdleTime(Config.DATABASE_MAX_IDLE_TIME); // 0 = idle connections never expire
-			// *THANKS* to connection testing configured above
-			// but I prefer to disconnect all connections not used
-			// for more than 1 hour
-			
-			// enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
-			_source.setMaxStatementsPerConnection(100);
-			
-			_source.setBreakAfterAcquireFailure(false); // never fail if any way possible
-			// setting this to true will make
-			// c3p0 "crash" and refuse to work
-			// till restart thus making acquire
-			// errors "FATAL" ... we don't want that
-			// it should be possible to recover
-			_source.setDriverClass(Config.DATABASE_DRIVER);
-			_source.setJdbcUrl(Config.DATABASE_URL);
-			_source.setUser(Config.DATABASE_LOGIN);
-			_source.setPassword(Config.DATABASE_PASSWORD);
-			
-			/* Test the connection */
-			_source.getConnection().close();
-			
-			if (Config.DEBUG)
-			{
-				_log.fine("Database Connection Working");
-			}
-		}
-		catch (SQLException x)
-		{
-			if (Config.DEBUG)
-			{
-				_log.fine("Database Connection FAILED");
-			}
-			// re-throw the exception
-			throw x;
-		}
-		catch (Exception e)
-		{
-			if (Config.DEBUG)
-			{
-				_log.fine("Database Connection FAILED");
-			}
-			throw new SQLException("Could not init DB connection:" + e.getMessage());
-		}
-	}
-	
-	/**
-	 * Shutdown.
-	 */
-	public void shutdown()
-	{
-		try
-		{
-			_source.close();
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.INFO, "", e);
-		}
-		try
-		{
-			_source = null;
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.INFO, "", e);
-		}
-	}
-	
-	/**
-	 * Gets the single instance of L2DatabaseFactory.
-	 * @return single instance of L2DatabaseFactory
-	 * @throws SQLException the SQL exception
-	 */
-	public static L2DatabaseFactory getInstance() throws SQLException
-	{
-		synchronized (L2DatabaseFactory.class)
-		{
-			if (_instance == null)
-			{
-				_instance = new L2DatabaseFactory();
-			}
-		}
-		return _instance;
-	}
-	
-	/**
-	 * Gets the connection.
-	 * @return the connection
-	 */
-	public Connection getConnection()
-	{
-		Connection con = null;
-		while (con == null)
-		{
-			try
-			{
-				con = _source.getConnection();
-				if (Server.serverMode == Server.MODE_GAMESERVER)
-				{
-					ThreadPoolManager.getInstance().scheduleGeneral(new ConnectionCloser(con, new RuntimeException()), Config.CONNECTION_CLOSE_TIME);
-				}
-				else
-				{
-					getExecutor().schedule(new ConnectionCloser(con, new RuntimeException()), Config.CONNECTION_CLOSE_TIME, TimeUnit.MILLISECONDS);
-				}
-			}
-			catch (SQLException e)
-			{
-				_log.log(Level.WARNING, "L2DatabaseFactory: getConnection() failed, trying again " + e.getMessage(), e);
-			}
-		}
-		return con;
-	}
-	
-	/**
-	 * The Class ConnectionCloser.
-	 */
-	private static class ConnectionCloser implements Runnable
-	{
-		private static final Logger _log = Logger.getLogger(ConnectionCloser.class.getName());
-		
-		/** The connection. */
-		private final Connection c;
-		
-		/** The exception. */
-		private final RuntimeException exp;
-		
-		/**
-		 * Instantiates a new connection closer.
-		 * @param con the con
-		 * @param e the e
-		 */
-		public ConnectionCloser(Connection con, RuntimeException e)
-		{
-			c = con;
-			exp = e;
-		}
-		
-		@Override
-		public void run()
-		{
-			try
-			{
-				if (!c.isClosed())
-				{
-					_log.log(Level.WARNING, "Unclosed connection! Trace: " + exp.getStackTrace()[1], exp);
-				}
-			}
-			catch (SQLException e)
-			{
-				_log.log(Level.WARNING, "", e);
-			}
-		}
-	}
-	
-	/**
-	 * Gets the executor.
-	 * @return the executor
-	 */
-	private static ScheduledExecutorService getExecutor()
-	{
-		if (_executor == null)
-		{
-			synchronized (L2DatabaseFactory.class)
-			{
-				if (_executor == null)
-				{
-					_executor = Executors.newSingleThreadScheduledExecutor();
-				}
-			}
-		}
-		return _executor;
-	}
-	
-	/**
-	 * Gets the busy connection count.
-	 * @return the busy connection count
-	 * @throws SQLException the SQL exception
-	 */
-	public int getBusyConnectionCount() throws SQLException
-	{
-		return _source.getNumBusyConnectionsDefaultUser();
-	}
-	
-	/**
-	 * Gets the idle connection count.
-	 * @return the idle connection count
-	 * @throws SQLException the SQL exception
-	 */
-	public int getIdleConnectionCount() throws SQLException
-	{
-		return _source.getNumIdleConnectionsDefaultUser();
-	}
-}

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/GameServer.java

@@ -31,9 +31,9 @@ import java.util.logging.LogManager;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.Server;
 import com.l2jserver.Server;
 import com.l2jserver.UPnPService;
 import com.l2jserver.UPnPService;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.data.sql.impl.AnnouncementsTable;
 import com.l2jserver.gameserver.data.sql.impl.AnnouncementsTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
@@ -463,7 +463,7 @@ public final class GameServer
 		// Initialize config
 		// Initialize config
 		Config.load();
 		Config.load();
 		printSection("Database");
 		printSection("Database");
-		L2DatabaseFactory.getInstance();
+		ConnectionFactory.getInstance();
 		gameServer = new GameServer();
 		gameServer = new GameServer();
 		
 		
 		if (Config.IS_TELNET_ENABLED)
 		if (Config.IS_TELNET_ENABLED)

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/LoginServerThread.java

@@ -45,7 +45,7 @@ import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.L2GameClient;
 import com.l2jserver.gameserver.network.L2GameClient;
@@ -578,7 +578,7 @@ public class LoginServerThread extends Thread
 		
 		
 		int chars = 0;
 		int chars = 0;
 		List<Long> charToDel = new ArrayList<>();
 		List<Long> charToDel = new ArrayList<>();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT deletetime FROM characters WHERE account_name=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT deletetime FROM characters WHERE account_name=?"))
 		{
 		{
 			ps.setString(1, account);
 			ps.setString(1, account);

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/SevenSigns.java

@@ -32,7 +32,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.instancemanager.CastleManager;
 import com.l2jserver.gameserver.instancemanager.CastleManager;
 import com.l2jserver.gameserver.model.AutoSpawnHandler;
 import com.l2jserver.gameserver.model.AutoSpawnHandler;
 import com.l2jserver.gameserver.model.AutoSpawnHandler.AutoSpawnInstance;
 import com.l2jserver.gameserver.model.AutoSpawnHandler.AutoSpawnInstance;
@@ -801,7 +801,7 @@ public class SevenSigns
 	 */
 	 */
 	protected void restoreSevenSignsData()
 	protected void restoreSevenSignsData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			try (Statement s = con.createStatement();
 			try (Statement s = con.createStatement();
 				ResultSet rs = s.executeQuery(LOAD_DATA))
 				ResultSet rs = s.executeQuery(LOAD_DATA))
@@ -868,7 +868,7 @@ public class SevenSigns
 	 */
 	 */
 	public void saveSevenSignsData()
 	public void saveSevenSignsData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(UPDATE_PLAYER))
 			PreparedStatement ps = con.prepareStatement(UPDATE_PLAYER))
 		{
 		{
 			for (StatsSet sevenDat : _signsPlayerData.values())
 			for (StatsSet sevenDat : _signsPlayerData.values())
@@ -899,7 +899,7 @@ public class SevenSigns
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(UPDATE_PLAYER))
 			PreparedStatement ps = con.prepareStatement(UPDATE_PLAYER))
 		{
 		{
 			ps.setString(1, sevenDat.getString("cabal"));
 			ps.setString(1, sevenDat.getString("cabal"));
@@ -920,7 +920,7 @@ public class SevenSigns
 	
 	
 	public final void saveSevenSignsStatus()
 	public final void saveSevenSignsStatus()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(UPDATE_STATUS))
 			PreparedStatement ps = con.prepareStatement(UPDATE_STATUS))
 		{
 		{
 			ps.setInt(1, _currentCycle);
 			ps.setInt(1, _currentCycle);
@@ -1007,7 +1007,7 @@ public class SevenSigns
 			_signsPlayerData.put(objectId, currPlayerData);
 			_signsPlayerData.put(objectId, currPlayerData);
 			
 			
 			// Update data in database, as we have a new player signing up.
 			// Update data in database, as we have a new player signing up.
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement(INSERT_PLAYER))
 				PreparedStatement ps = con.prepareStatement(INSERT_PLAYER))
 			{
 			{
 				ps.setInt(1, objectId);
 				ps.setInt(1, objectId);

+ 5 - 5
L2J_Server/java/com/l2jserver/gameserver/SevenSignsFestival.java

@@ -33,7 +33,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
@@ -924,7 +924,7 @@ public class SevenSignsFestival implements SpawnListener
 	 */
 	 */
 	protected void restoreFestivalData()
 	protected void restoreFestivalData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT festivalId, cabal, cycle, date, score, members " + "FROM seven_signs_festival"))
 			ResultSet rs = s.executeQuery("SELECT festivalId, cabal, cycle, date, score, members " + "FROM seven_signs_festival"))
 		{
 		{
@@ -972,7 +972,7 @@ public class SevenSignsFestival implements SpawnListener
 		query.append(' ');
 		query.append(' ');
 		query.append("FROM seven_signs_status WHERE id=0");
 		query.append("FROM seven_signs_status WHERE id=0");
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery(query.toString()))
 			ResultSet rs = s.executeQuery(query.toString()))
 		{
 		{
@@ -998,7 +998,7 @@ public class SevenSignsFestival implements SpawnListener
 	 */
 	 */
 	public void saveFestivalData(boolean updateSettings)
 	public void saveFestivalData(boolean updateSettings)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement psUpdate = con.prepareStatement("UPDATE seven_signs_festival SET date=?, score=?, members=? WHERE cycle=? AND cabal=? AND festivalId=?");
 			PreparedStatement psUpdate = con.prepareStatement("UPDATE seven_signs_festival SET date=?, score=?, members=? WHERE cycle=? AND cabal=? AND festivalId=?");
 			PreparedStatement psInsert = con.prepareStatement("INSERT INTO seven_signs_festival (festivalId, cabal, cycle, date, score, members) VALUES (?,?,?,?,?,?)"))
 			PreparedStatement psInsert = con.prepareStatement("INSERT INTO seven_signs_festival (festivalId, cabal, cycle, date, score, members) VALUES (?,?,?,?,?,?)"))
 		{
 		{
@@ -1121,7 +1121,7 @@ public class SevenSignsFestival implements SpawnListener
 		}
 		}
 		else
 		else
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement(GET_CLAN_NAME))
 				PreparedStatement ps = con.prepareStatement(GET_CLAN_NAME))
 			{
 			{
 				ps.setString(1, partyMemberName);
 				ps.setString(1, partyMemberName);

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/Shutdown.java

@@ -22,8 +22,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.UPnPService;
 import com.l2jserver.UPnPService;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.OfflineTradersTable;
 import com.l2jserver.gameserver.data.sql.impl.OfflineTradersTable;
 import com.l2jserver.gameserver.datatables.BotReportTable;
 import com.l2jserver.gameserver.datatables.BotReportTable;
@@ -271,7 +271,7 @@ public class Shutdown extends Thread
 			// commit data, last chance
 			// commit data, last chance
 			try
 			try
 			{
 			{
-				L2DatabaseFactory.getInstance().shutdown();
+				ConnectionFactory.getInstance().close();
 				_log.info("L2Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
 				_log.info("L2Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
 			}
 			}
 			catch (Throwable t)
 			catch (Throwable t)

+ 5 - 5
L2J_Server/java/com/l2jserver/gameserver/communitybbs/BB/Forum.java

@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.TopicBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.TopicBBSManager;
 
 
@@ -93,7 +93,7 @@ public class Forum
 	
 	
 	private void load()
 	private void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?"))
 		{
 		{
 			ps.setInt(1, _forumId);
 			ps.setInt(1, _forumId);
@@ -114,7 +114,7 @@ public class Forum
 			_log.log(Level.WARNING, "Data error on Forum " + _forumId + " : " + e.getMessage(), e);
 			_log.log(Level.WARNING, "Data error on Forum " + _forumId + " : " + e.getMessage(), e);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM topic WHERE topic_forum_id=? ORDER BY topic_id DESC"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM topic WHERE topic_forum_id=? ORDER BY topic_id DESC"))
 		{
 		{
 			ps.setInt(1, _forumId);
 			ps.setInt(1, _forumId);
@@ -139,7 +139,7 @@ public class Forum
 	
 	
 	private void getChildren()
 	private void getChildren()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_parent=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_parent=?"))
 		{
 		{
 			ps.setInt(1, _forumId);
 			ps.setInt(1, _forumId);
@@ -218,7 +218,7 @@ public class Forum
 	
 	
 	public void insertIntoDb()
 	public void insertIntoDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO forums (forum_id,forum_name,forum_parent,forum_post,forum_type,forum_perm,forum_owner_id) VALUES (?,?,?,?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO forums (forum_id,forum_name,forum_parent,forum_post,forum_type,forum_perm,forum_owner_id) VALUES (?,?,?,?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, _forumId);
 			ps.setInt(1, _forumId);

+ 5 - 5
L2J_Server/java/com/l2jserver/gameserver/communitybbs/BB/Post.java

@@ -26,7 +26,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.communitybbs.Manager.PostBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.PostBBSManager;
 
 
 /**
 /**
@@ -79,7 +79,7 @@ public class Post
 	
 	
 	public void insertindb(CPost cp)
 	public void insertindb(CPost cp)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, cp.postId);
 			ps.setInt(1, cp.postId);
@@ -105,7 +105,7 @@ public class Post
 	public void deleteme(Topic t)
 	public void deleteme(Topic t)
 	{
 	{
 		PostBBSManager.getInstance().delPostByTopic(t);
 		PostBBSManager.getInstance().delPostByTopic(t);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM posts WHERE post_forum_id=? AND post_topic_id=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM posts WHERE post_forum_id=? AND post_topic_id=?"))
 		{
 		{
 			ps.setInt(1, t.getForumID());
 			ps.setInt(1, t.getForumID());
@@ -123,7 +123,7 @@ public class Post
 	 */
 	 */
 	private void load(Topic t)
 	private void load(Topic t)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM posts WHERE post_forum_id=? AND post_topic_id=? ORDER BY post_id ASC"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM posts WHERE post_forum_id=? AND post_topic_id=? ORDER BY post_id ASC"))
 		{
 		{
 			ps.setInt(1, t.getForumID());
 			ps.setInt(1, t.getForumID());
@@ -155,7 +155,7 @@ public class Post
 	 */
 	 */
 	public void updatetxt(int i)
 	public void updatetxt(int i)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE posts SET post_txt=? WHERE post_id=? AND post_topic_id=? AND post_forum_id=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE posts SET post_txt=? WHERE post_id=? AND post_topic_id=? AND post_forum_id=?"))
 		{
 		{
 			CPost cp = getCPost(i);
 			CPost cp = getCPost(i);

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/communitybbs/BB/Topic.java

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.communitybbs.Manager.TopicBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.TopicBBSManager;
 
 
 public class Topic
 public class Topic
@@ -74,7 +74,7 @@ public class Topic
 	
 	
 	public void insertindb()
 	public void insertindb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, _id);
 			ps.setInt(1, _id);
@@ -132,7 +132,7 @@ public class Topic
 	{
 	{
 		TopicBBSManager.getInstance().delTopic(this);
 		TopicBBSManager.getInstance().delTopic(this);
 		f.rmTopicByID(getID());
 		f.rmTopicByID(getID());
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?"))
 		{
 		{
 			ps.setInt(1, getID());
 			ps.setInt(1, getID());

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/communitybbs/Manager/ForumsBBSManager.java

@@ -26,7 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.communitybbs.BB.Forum;
 import com.l2jserver.gameserver.communitybbs.BB.Forum;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
@@ -41,7 +41,7 @@ public class ForumsBBSManager extends BaseBBSManager
 	 */
 	 */
 	protected ForumsBBSManager()
 	protected ForumsBBSManager()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT forum_id FROM forums WHERE forum_type = 0"))
 			ResultSet rs = s.executeQuery("SELECT forum_id FROM forums WHERE forum_type = 0"))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/AnnouncementsTable.java

@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.announce.Announcement;
 import com.l2jserver.gameserver.model.announce.Announcement;
 import com.l2jserver.gameserver.model.announce.AnnouncementType;
 import com.l2jserver.gameserver.model.announce.AnnouncementType;
@@ -54,7 +54,7 @@ public final class AnnouncementsTable
 	private void load()
 	private void load()
 	{
 	{
 		_announcements.clear();
 		_announcements.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement st = con.createStatement();
 			Statement st = con.createStatement();
 			ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
 			ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
 		{
 		{

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/CharNameTable.java

@@ -30,7 +30,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
 /**
 /**
@@ -101,7 +101,7 @@ public class CharNameTable
 		int id = -1;
 		int id = -1;
 		int accessLevel = 0;
 		int accessLevel = 0;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?"))
 		{
 		{
 			ps.setString(1, name);
 			ps.setString(1, name);
@@ -147,7 +147,7 @@ public class CharNameTable
 			return null;
 			return null;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT char_name,accesslevel FROM characters WHERE charId=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT char_name,accesslevel FROM characters WHERE charId=?"))
 		{
 		{
 			ps.setInt(1, id);
 			ps.setInt(1, id);
@@ -183,7 +183,7 @@ public class CharNameTable
 	public synchronized boolean doesCharNameExist(String name)
 	public synchronized boolean doesCharNameExist(String name)
 	{
 	{
 		boolean result = true;
 		boolean result = true;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT account_name FROM characters WHERE char_name=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT account_name FROM characters WHERE char_name=?"))
 		{
 		{
 			ps.setString(1, name);
 			ps.setString(1, name);
@@ -201,7 +201,7 @@ public class CharNameTable
 	
 	
 	public int getAccountCharacterCount(String account)
 	public int getAccountCharacterCount(String account)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT COUNT(char_name) FROM characters WHERE account_name=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT COUNT(char_name) FROM characters WHERE account_name=?"))
 		{
 		{
 			ps.setString(1, account);
 			ps.setString(1, account);
@@ -222,7 +222,7 @@ public class CharNameTable
 	
 	
 	private void loadAll()
 	private void loadAll()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT charId, char_name, accesslevel FROM characters"))
 			ResultSet rs = s.executeQuery("SELECT charId, char_name, accesslevel FROM characters"))
 		{
 		{

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/CharSummonTable.java

@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
 import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.datatables.SkillData;
@@ -71,7 +71,7 @@ public class CharSummonTable
 	{
 	{
 		if (Config.RESTORE_SERVITOR_ON_RECONNECT)
 		if (Config.RESTORE_SERVITOR_ON_RECONNECT)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				Statement s = con.createStatement();
 				Statement s = con.createStatement();
 				ResultSet rs = s.executeQuery(INIT_SUMMONS))
 				ResultSet rs = s.executeQuery(INIT_SUMMONS))
 			{
 			{
@@ -88,7 +88,7 @@ public class CharSummonTable
 		
 		
 		if (Config.RESTORE_PET_ON_RECONNECT)
 		if (Config.RESTORE_PET_ON_RECONNECT)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				Statement s = con.createStatement();
 				Statement s = con.createStatement();
 				ResultSet rs = s.executeQuery(INIT_PET))
 				ResultSet rs = s.executeQuery(INIT_PET))
 			{
 			{
@@ -107,7 +107,7 @@ public class CharSummonTable
 	public void removeServitor(L2PcInstance activeChar)
 	public void removeServitor(L2PcInstance activeChar)
 	{
 	{
 		_servitors.remove(activeChar.getObjectId());
 		_servitors.remove(activeChar.getObjectId());
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
 			PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
 		{
 		{
 			ps.setInt(1, activeChar.getObjectId());
 			ps.setInt(1, activeChar.getObjectId());
@@ -177,7 +177,7 @@ public class CharSummonTable
 	public void restoreServitor(L2PcInstance activeChar)
 	public void restoreServitor(L2PcInstance activeChar)
 	{
 	{
 		int skillId = _servitors.get(activeChar.getObjectId());
 		int skillId = _servitors.get(activeChar.getObjectId());
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
 			PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
 		{
 		{
 			ps.setInt(1, activeChar.getObjectId());
 			ps.setInt(1, activeChar.getObjectId());
@@ -225,7 +225,7 @@ public class CharSummonTable
 		
 		
 		_servitors.put(summon.getOwner().getObjectId(), summon.getReferenceSkill());
 		_servitors.put(summon.getOwner().getObjectId(), summon.getReferenceSkill());
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(SAVE_SUMMON))
 			PreparedStatement ps = con.prepareStatement(SAVE_SUMMON))
 		{
 		{
 			ps.setInt(1, summon.getOwner().getObjectId());
 			ps.setInt(1, summon.getOwner().getObjectId());

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/ClanTable.java

@@ -31,7 +31,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
@@ -84,7 +84,7 @@ public class ClanTable
 		L2Clan clan;
 		L2Clan clan;
 		// Count the clans
 		// Count the clans
 		int clanCount = 0;
 		int clanCount = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
 			ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
 		{
 		{
@@ -278,7 +278,7 @@ public class ClanTable
 		_clans.remove(clanId);
 		_clans.remove(clanId);
 		IdFactory.getInstance().releaseId(clanId);
 		IdFactory.getInstance().releaseId(clanId);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM clan_data WHERE clan_id=?"))
 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM clan_data WHERE clan_id=?"))
 			{
 			{
@@ -395,7 +395,7 @@ public class ClanTable
 		clan2.setAttackerClan(clan1);
 		clan2.setAttackerClan(clan1);
 		clan1.broadcastClanStatus();
 		clan1.broadcastClanStatus();
 		clan2.broadcastClanStatus();
 		clan2.broadcastClanStatus();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, wantspeace1, wantspeace2) VALUES(?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, wantspeace1, wantspeace2) VALUES(?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, clanId1);
 			ps.setInt(1, clanId1);
@@ -435,7 +435,7 @@ public class ClanTable
 		clan1.broadcastClanStatus();
 		clan1.broadcastClanStatus();
 		clan2.broadcastClanStatus();
 		clan2.broadcastClanStatus();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? AND clan2=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? AND clan2=?"))
 		{
 		{
 			ps.setInt(1, clanId1);
 			ps.setInt(1, clanId1);
@@ -477,7 +477,7 @@ public class ClanTable
 	private void restorewars()
 	private void restorewars()
 	{
 	{
 		L2Clan clan1, clan2;
 		L2Clan clan1, clan2;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement statement = con.createStatement();
 			Statement statement = con.createStatement();
 			ResultSet rset = statement.executeQuery("SELECT clan1, clan2 FROM clan_wars"))
 			ResultSet rset = statement.executeQuery("SELECT clan1, clan2 FROM clan_wars"))
 		{
 		{

+ 12 - 14
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/CrestTable.java

@@ -34,7 +34,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Crest;
 import com.l2jserver.gameserver.model.L2Crest;
 import com.l2jserver.gameserver.model.L2Crest.CrestType;
 import com.l2jserver.gameserver.model.L2Crest.CrestType;
@@ -78,7 +78,7 @@ public final class CrestTable
 			}
 			}
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement statement = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
 			Statement statement = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
 			ResultSet rs = statement.executeQuery("SELECT `crest_id`, `data`, `type` FROM `crests` ORDER BY `crest_id` DESC"))
 			ResultSet rs = statement.executeQuery("SELECT `crest_id`, `data`, `type` FROM `crests` ORDER BY `crest_id` DESC"))
 		{
 		{
@@ -261,18 +261,16 @@ public final class CrestTable
 	 */
 	 */
 	public L2Crest createCrest(byte[] data, CrestType crestType)
 	public L2Crest createCrest(byte[] data, CrestType crestType)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
 		{
 		{
-			try (PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
-			{
-				final L2Crest crest = new L2Crest(getNextId(), data, crestType);
-				statement.setInt(1, crest.getId());
-				statement.setBytes(2, crest.getData());
-				statement.setInt(3, crest.getType().getId());
-				statement.executeUpdate();
-				_crests.put(crest.getId(), crest);
-				return crest;
-			}
+			final L2Crest crest = new L2Crest(getNextId(), data, crestType);
+			statement.setInt(1, crest.getId());
+			statement.setBytes(2, crest.getData());
+			statement.setInt(3, crest.getType().getId());
+			statement.executeUpdate();
+			_crests.put(crest.getId(), crest);
+			return crest;
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -296,7 +294,7 @@ public final class CrestTable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("DELETE FROM `crests` WHERE `crest_id` = ?"))
 			PreparedStatement statement = con.prepareStatement("DELETE FROM `crests` WHERE `crest_id` = ?"))
 		{
 		{
 			statement.setInt(1, crestId);
 			statement.setInt(1, crestId);

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/NpcBufferTable.java

@@ -28,7 +28,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.holders.ItemHolder;
 import com.l2jserver.gameserver.model.holders.ItemHolder;
 import com.l2jserver.gameserver.model.holders.SkillHolder;
 import com.l2jserver.gameserver.model.holders.SkillHolder;
 
 
@@ -90,7 +90,7 @@ public class NpcBufferTable
 	protected NpcBufferTable()
 	protected NpcBufferTable()
 	{
 	{
 		int skillCount = 0;
 		int skillCount = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rset = s.executeQuery("SELECT `npc_id`,`skill_id`,`skill_level`,`skill_fee_id`,`skill_fee_amount`,`buff_group` FROM `npc_buffer` ORDER BY `npc_id` ASC"))
 			ResultSet rset = s.executeQuery("SELECT `npc_id`,`skill_id`,`skill_level`,`skill_fee_id`,`skill_fee_amount`,`buff_group` FROM `npc_buffer` ORDER BY `npc_id` ASC"))
 		{
 		{
@@ -137,7 +137,7 @@ public class NpcBufferTable
 		
 		
 		if (Config.CUSTOM_NPCBUFFER_TABLES)
 		if (Config.CUSTOM_NPCBUFFER_TABLES)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				Statement s = con.createStatement();
 				Statement s = con.createStatement();
 				ResultSet rset = s.executeQuery("SELECT `npc_id`,`skill_id`,`skill_level`,`skill_fee_id`,`skill_fee_amount`,`buff_group` FROM `custom_npc_buffer` ORDER BY `npc_id` ASC"))
 				ResultSet rset = s.executeQuery("SELECT `npc_id`,`skill_id`,`skill_level`,`skill_fee_id`,`skill_fee_amount`,`buff_group` FROM `custom_npc_buffer` ORDER BY `npc_id` ASC"))
 			{
 			{

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/OfflineTradersTable.java

@@ -27,7 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.LoginServerThread;
 import com.l2jserver.gameserver.LoginServerThread;
 import com.l2jserver.gameserver.enums.PrivateStoreType;
 import com.l2jserver.gameserver.enums.PrivateStoreType;
 import com.l2jserver.gameserver.model.L2ManufactureItem;
 import com.l2jserver.gameserver.model.L2ManufactureItem;
@@ -51,7 +51,7 @@ public class OfflineTradersTable
 	
 	
 	public void storeOffliners()
 	public void storeOffliners()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE);
 			PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE);
 			PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS);
 			PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS);
 			PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS);
 			PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS);
@@ -146,7 +146,7 @@ public class OfflineTradersTable
 	{
 	{
 		LOGGER.info(getClass().getSimpleName() + ": Loading offline traders...");
 		LOGGER.info(getClass().getSimpleName() + ": Loading offline traders...");
 		int nTraders = 0;
 		int nTraders = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement stm = con.createStatement();
 			Statement stm = con.createStatement();
 			ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS))
 			ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/PetNameTable.java

@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 import java.util.regex.PatternSyntaxException;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
 import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
 
 
 public class PetNameTable
 public class PetNameTable
@@ -44,7 +44,7 @@ public class PetNameTable
 	public boolean doesPetNameExist(String name, int petNpcId)
 	public boolean doesPetNameExist(String name, int petNpcId)
 	{
 	{
 		boolean result = true;
 		boolean result = true;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT name FROM pets p, items i WHERE p.item_obj_id = i.object_id AND name=? AND i.item_id IN (?)"))
 			PreparedStatement ps = con.prepareStatement("SELECT name FROM pets p, items i WHERE p.item_obj_id = i.object_id AND name=? AND i.item_id IN (?)"))
 		{
 		{
 			ps.setString(1, name);
 			ps.setString(1, name);

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/SummonSkillsTable.java

@@ -29,7 +29,7 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.actor.L2Summon;
 
 
@@ -47,7 +47,7 @@ public class SummonSkillsTable
 	{
 	{
 		_skillTrees.clear();
 		_skillTrees.clear();
 		int count = 0;
 		int count = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
 			ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
 		{
 		{

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/TeleportLocationTable.java

@@ -27,7 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2TeleportLocation;
 import com.l2jserver.gameserver.model.L2TeleportLocation;
 
 
 public class TeleportLocationTable
 public class TeleportLocationTable
@@ -44,7 +44,7 @@ public class TeleportLocationTable
 	public void reloadAll()
 	public void reloadAll()
 	{
 	{
 		_teleports.clear();
 		_teleports.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM teleport"))
 			ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM teleport"))
 		{
 		{
@@ -73,7 +73,7 @@ public class TeleportLocationTable
 		if (Config.CUSTOM_TELEPORT_TABLE)
 		if (Config.CUSTOM_TELEPORT_TABLE)
 		{
 		{
 			int _cTeleCount = _teleports.size();
 			int _cTeleCount = _teleports.size();
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				Statement s = con.createStatement();
 				Statement s = con.createStatement();
 				ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM custom_teleport"))
 				ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM custom_teleport"))
 			{
 			{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/data/sql/impl/TerritoryTable.java

@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2Territory;
 import com.l2jserver.gameserver.model.L2Territory;
 import com.l2jserver.gameserver.model.Location;
 import com.l2jserver.gameserver.model.Location;
 
 
@@ -74,7 +74,7 @@ public class TerritoryTable
 	public void load()
 	public void load()
 	{
 	{
 		_territory.clear();
 		_territory.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement stmt = con.createStatement();
 			Statement stmt = con.createStatement();
 			ResultSet rset = stmt.executeQuery("SELECT * FROM locations WHERE loc_id>0"))
 			ResultSet rset = stmt.executeQuery("SELECT * FROM locations WHERE loc_id>0"))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/data/xml/impl/BuyListData.java

@@ -32,7 +32,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.model.buylist.L2BuyList;
 import com.l2jserver.gameserver.model.buylist.L2BuyList;
 import com.l2jserver.gameserver.model.buylist.Product;
 import com.l2jserver.gameserver.model.buylist.Product;
@@ -66,7 +66,7 @@ public final class BuyListData implements IXmlReader
 		
 		
 		LOGGER.info(getClass().getSimpleName() + ": Loaded " + _buyLists.size() + " BuyLists.");
 		LOGGER.info(getClass().getSimpleName() + ": Loaded " + _buyLists.size() + " BuyLists.");
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement statement = con.createStatement();
 			Statement statement = con.createStatement();
 			ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`"))
 			ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`"))
 		{
 		{

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/datatables/BotReportTable.java

@@ -38,7 +38,7 @@ import org.xml.sax.Attributes;
 import org.xml.sax.helpers.DefaultHandler;
 import org.xml.sax.helpers.DefaultHandler;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Object;
@@ -111,7 +111,7 @@ public final class BotReportTable
 	 */
 	 */
 	private void loadReportedCharData()
 	private void loadReportedCharData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement st = con.createStatement();
 			Statement st = con.createStatement();
 			ResultSet rset = st.executeQuery(SQL_LOAD_REPORTED_CHAR_DATA))
 			ResultSet rset = st.executeQuery(SQL_LOAD_REPORTED_CHAR_DATA))
 		{
 		{
@@ -181,7 +181,7 @@ public final class BotReportTable
 	 */
 	 */
 	public void saveReportedCharData()
 	public void saveReportedCharData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement st = con.createStatement();
 			Statement st = con.createStatement();
 			PreparedStatement ps = con.prepareStatement(SQL_INSERT_REPORTED_CHAR_DATA))
 			PreparedStatement ps = con.prepareStatement(SQL_INSERT_REPORTED_CHAR_DATA))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/datatables/ItemTable.java

@@ -31,7 +31,7 @@ import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.xml.impl.EnchantItemHPBonusData;
 import com.l2jserver.gameserver.data.xml.impl.EnchantItemHPBonusData;
 import com.l2jserver.gameserver.engines.DocumentEngine;
 import com.l2jserver.gameserver.engines.DocumentEngine;
@@ -360,7 +360,7 @@ public class ItemTable
 			// if it's a pet control item, delete the pet as well
 			// if it's a pet control item, delete the pet as well
 			if (item.getItem().isPetItem())
 			if (item.getItem().isPetItem())
 			{
 			{
-				try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+				try (Connection con = ConnectionFactory.getInstance().getConnection();
 					PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
 					PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
 				{
 				{
 					// Delete the pet in db
 					// Delete the pet in db

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/datatables/SpawnTable.java

@@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.instancemanager.DayNightSpawnManager;
 import com.l2jserver.gameserver.instancemanager.DayNightSpawnManager;
 import com.l2jserver.gameserver.instancemanager.ZoneManager;
 import com.l2jserver.gameserver.instancemanager.ZoneManager;
@@ -253,7 +253,7 @@ public final class SpawnTable implements IXmlReader
 	private int fillSpawnTable(boolean isCustom)
 	private int fillSpawnTable(boolean isCustom)
 	{
 	{
 		int npcSpawnCount = 0;
 		int npcSpawnCount = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery(isCustom ? SELECT_CUSTOM_SPAWNS : SELECT_SPAWNS))
 			ResultSet rs = s.executeQuery(isCustom ? SELECT_CUSTOM_SPAWNS : SELECT_SPAWNS))
 		{
 		{
@@ -410,7 +410,7 @@ public final class SpawnTable implements IXmlReader
 		if (storeInDb)
 		if (storeInDb)
 		{
 		{
 			final String spawnTable = spawn.isCustom() && Config.CUSTOM_SPAWNLIST_TABLE ? "custom_spawnlist" : "spawnlist";
 			final String spawnTable = spawn.isCustom() && Config.CUSTOM_SPAWNLIST_TABLE ? "custom_spawnlist" : "spawnlist";
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement insert = con.prepareStatement("INSERT INTO " + spawnTable + "(count,npc_templateid,locx,locy,locz,heading,respawn_delay,respawn_random,loc_id) values(?,?,?,?,?,?,?,?,?)"))
 				PreparedStatement insert = con.prepareStatement("INSERT INTO " + spawnTable + "(count,npc_templateid,locx,locy,locz,heading,respawn_delay,respawn_random,loc_id) values(?,?,?,?,?,?,?,?,?)"))
 			{
 			{
 				insert.setInt(1, spawn.getAmount());
 				insert.setInt(1, spawn.getAmount());
@@ -445,7 +445,7 @@ public final class SpawnTable implements IXmlReader
 		
 		
 		if (updateDb)
 		if (updateDb)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement delete = con.prepareStatement("DELETE FROM " + (spawn.isCustom() ? "custom_spawnlist" : "spawnlist") + " WHERE locx=? AND locy=? AND locz=? AND npc_templateid=? AND heading=?"))
 				PreparedStatement delete = con.prepareStatement("DELETE FROM " + (spawn.isCustom() ? "custom_spawnlist" : "spawnlist") + " WHERE locx=? AND locy=? AND locz=? AND npc_templateid=? AND heading=?"))
 			{
 			{
 				delete.setInt(1, spawn.getX());
 				delete.setInt(1, spawn.getX());

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/idfactory/CompactionIDFactory.java

@@ -24,7 +24,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLException;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 
 
 /**
 /**
  * 18.8.2010 - JIV: Disabling until someone update it
  * 18.8.2010 - JIV: Disabling until someone update it
@@ -41,7 +41,7 @@ public class CompactionIDFactory extends IdFactory
 		_curOID = FIRST_OID;
 		_curOID = FIRST_OID;
 		_freeSize = 0;
 		_freeSize = 0;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			Integer[] tmp_obj_ids = extractUsedObjectIDTable();
 			Integer[] tmp_obj_ids = extractUsedObjectIDTable();
 			
 			

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/idfactory/IdFactory.java

@@ -30,7 +30,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 
 
 /**
 /**
  * This class ...
  * This class ...
@@ -174,7 +174,7 @@ public abstract class IdFactory
 	 */
 	 */
 	private void setAllCharacterOffline()
 	private void setAllCharacterOffline()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement())
 			Statement s = con.createStatement())
 		{
 		{
 			s.executeUpdate("UPDATE characters SET online = 0");
 			s.executeUpdate("UPDATE characters SET online = 0");
@@ -191,7 +191,7 @@ public abstract class IdFactory
 	 */
 	 */
 	private void cleanUpDB()
 	private void cleanUpDB()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement stmt = con.createStatement())
 			Statement stmt = con.createStatement())
 		{
 		{
 			long cleanupStart = System.currentTimeMillis();
 			long cleanupStart = System.currentTimeMillis();
@@ -305,7 +305,7 @@ public abstract class IdFactory
 	
 	
 	private void cleanInvalidWeddings()
 	private void cleanInvalidWeddings()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement())
 			Statement s = con.createStatement())
 		{
 		{
 			s.executeUpdate("DELETE FROM mods_wedding WHERE player1Id NOT IN (SELECT charId FROM characters)");
 			s.executeUpdate("DELETE FROM mods_wedding WHERE player1Id NOT IN (SELECT charId FROM characters)");
@@ -320,7 +320,7 @@ public abstract class IdFactory
 	
 	
 	private void cleanUpTimeStamps()
 	private void cleanUpTimeStamps()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			int cleanCount = 0;
 			int cleanCount = 0;
 			for (String line : TIMESTAMPS_CLEAN)
 			for (String line : TIMESTAMPS_CLEAN)
@@ -346,7 +346,7 @@ public abstract class IdFactory
 	protected final Integer[] extractUsedObjectIDTable() throws Exception
 	protected final Integer[] extractUsedObjectIDTable() throws Exception
 	{
 	{
 		final List<Integer> temp = new ArrayList<>();
 		final List<Integer> temp = new ArrayList<>();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement())
 			Statement s = con.createStatement())
 		{
 		{
 			
 			

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/idfactory/StackIDFactory.java

@@ -25,7 +25,7 @@ import java.sql.SQLException;
 import java.util.Stack;
 import java.util.Stack;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 
 
 /**
 /**
  * This class ...
  * This class ...
@@ -44,7 +44,7 @@ public class StackIDFactory extends IdFactory
 		_curOID = FIRST_OID;
 		_curOID = FIRST_OID;
 		_tempOID = FIRST_OID;
 		_tempOID = FIRST_OID;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			// con.createStatement().execute("drop table if exists tmp_obj_id");
 			// con.createStatement().execute("drop table if exists tmp_obj_id");
 			
 			

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/instancemanager/AirShipManager.java

@@ -28,7 +28,7 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.AirShipTeleportList;
 import com.l2jserver.gameserver.model.AirShipTeleportList;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.VehiclePathPoint;
 import com.l2jserver.gameserver.model.VehiclePathPoint;
@@ -171,7 +171,7 @@ public class AirShipManager
 			
 			
 			_airShipsInfo.put(ownerId, info);
 			_airShipsInfo.put(ownerId, info);
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement(ADD_DB))
 				PreparedStatement ps = con.prepareStatement(ADD_DB))
 			{
 			{
 				ps.setInt(1, ownerId);
 				ps.setInt(1, ownerId);
@@ -267,7 +267,7 @@ public class AirShipManager
 	
 	
 	private void load()
 	private void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery(LOAD_DB))
 			ResultSet rs = s.executeQuery(LOAD_DB))
 		{
 		{
@@ -298,7 +298,7 @@ public class AirShipManager
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(UPDATE_DB))
 			PreparedStatement ps = con.prepareStatement(UPDATE_DB))
 		{
 		{
 			ps.setInt(1, info.getInt("fuel"));
 			ps.setInt(1, info.getInt("fuel"));

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/instancemanager/AuctionManager.java

@@ -26,7 +26,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.entity.Auction;
 import com.l2jserver.gameserver.model.entity.Auction;
 
 
 /**
 /**
@@ -100,7 +100,7 @@ public final class AuctionManager
 	
 	
 	private final void load()
 	private final void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT id FROM auction ORDER BY id"))
 			ResultSet rs = s.executeQuery("SELECT id FROM auction ORDER BY id"))
 		{
 		{
@@ -165,7 +165,7 @@ public final class AuctionManager
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement())
 			Statement s = con.createStatement())
 		{
 		{
 			s.executeUpdate("INSERT INTO `auction` VALUES " + ITEM_INIT_DATA[i]);
 			s.executeUpdate("INSERT INTO `auction` VALUES " + ITEM_INIT_DATA[i]);

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/CHSiegeManager.java

@@ -26,7 +26,7 @@ import java.util.Map;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -54,7 +54,7 @@ public final class CHSiegeManager
 	
 	
 	private final void loadClanHalls()
 	private final void loadClanHalls()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery(SQL_LOAD_HALLS))
 			ResultSet rs = s.executeQuery(SQL_LOAD_HALLS))
 		{
 		{

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/instancemanager/CastleManager.java

@@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.InstanceListManager;
 import com.l2jserver.gameserver.InstanceListManager;
 import com.l2jserver.gameserver.SevenSigns;
 import com.l2jserver.gameserver.SevenSigns;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
@@ -277,7 +277,7 @@ public final class CastleManager implements InstanceListManager
 				}
 				}
 			}
 			}
 			// else offline-player circlet removal
 			// else offline-player circlet removal
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE owner_id = ? and item_id = ?"))
 				PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE owner_id = ? and item_id = ?"))
 			{
 			{
 				ps.setInt(1, member.getObjectId());
 				ps.setInt(1, member.getObjectId());
@@ -294,7 +294,7 @@ public final class CastleManager implements InstanceListManager
 	@Override
 	@Override
 	public void loadInstances()
 	public void loadInstances()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT id FROM castle ORDER BY id"))
 			ResultSet rs = s.executeQuery("SELECT id FROM castle ORDER BY id"))
 		{
 		{

+ 8 - 8
L2J_Server/java/com/l2jserver/gameserver/instancemanager/CastleManorManager.java

@@ -38,7 +38,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.enums.ManorMode;
 import com.l2jserver.gameserver.enums.ManorMode;
 import com.l2jserver.gameserver.model.CropProcure;
 import com.l2jserver.gameserver.model.CropProcure;
@@ -166,7 +166,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 	
 	
 	private final void loadDb()
 	private final void loadDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement stProduction = con.prepareStatement("SELECT * FROM castle_manor_production WHERE castle_id=?");
 			PreparedStatement stProduction = con.prepareStatement("SELECT * FROM castle_manor_production WHERE castle_id=?");
 			PreparedStatement stProcure = con.prepareStatement("SELECT * FROM castle_manor_procure WHERE castle_id=?"))
 			PreparedStatement stProcure = con.prepareStatement("SELECT * FROM castle_manor_procure WHERE castle_id=?"))
 		{
 		{
@@ -438,7 +438,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 		_productionNext.put(castleId, list);
 		_productionNext.put(castleId, list);
 		if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
 		if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ? AND next_period = 1");
 				PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ? AND next_period = 1");
 				PreparedStatement ips = con.prepareStatement(INSERT_PRODUCT))
 				PreparedStatement ips = con.prepareStatement(INSERT_PRODUCT))
 			{
 			{
@@ -474,7 +474,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 		_procureNext.put(castleId, list);
 		_procureNext.put(castleId, list);
 		if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
 		if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ? AND next_period = 1");
 				PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ? AND next_period = 1");
 				PreparedStatement ips = con.prepareStatement(INSERT_CROP))
 				PreparedStatement ips = con.prepareStatement(INSERT_CROP))
 			{
 			{
@@ -508,7 +508,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 	
 	
 	public final void updateCurrentProduction(int castleId, Collection<SeedProduction> items)
 	public final void updateCurrentProduction(int castleId, Collection<SeedProduction> items)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_production SET amount = ? WHERE castle_id = ? AND seed_id = ? AND next_period = 0"))
 			PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_production SET amount = ? WHERE castle_id = ? AND seed_id = ? AND next_period = 0"))
 		{
 		{
 			for (SeedProduction sp : items)
 			for (SeedProduction sp : items)
@@ -528,7 +528,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 	
 	
 	public final void updateCurrentProcure(int castleId, Collection<CropProcure> items)
 	public final void updateCurrentProcure(int castleId, Collection<CropProcure> items)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_procure SET amount = ? WHERE castle_id = ? AND crop_id = ? AND next_period = 0"))
 			PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_procure SET amount = ? WHERE castle_id = ? AND crop_id = ? AND next_period = 0"))
 		{
 		{
 			for (CropProcure sp : items)
 			for (CropProcure sp : items)
@@ -601,7 +601,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 	@Override
 	@Override
 	public final boolean storeMe()
 	public final boolean storeMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production");
 			PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production");
 			PreparedStatement is = con.prepareStatement(INSERT_PRODUCT);
 			PreparedStatement is = con.prepareStatement(INSERT_PRODUCT);
 			PreparedStatement dp = con.prepareStatement("DELETE FROM castle_manor_procure");
 			PreparedStatement dp = con.prepareStatement("DELETE FROM castle_manor_procure");
@@ -699,7 +699,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
 		
 		
 		if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
 		if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ?");
 				PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ?");
 				PreparedStatement dc = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ?"))
 				PreparedStatement dc = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ?"))
 			{
 			{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/ClanHallManager.java

@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Object;
@@ -64,7 +64,7 @@ public final class ClanHallManager
 	/** Load All Clan Hall */
 	/** Load All Clan Hall */
 	private final void load()
 	private final void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM clanhall ORDER BY id"))
 			ResultSet rs = s.executeQuery("SELECT * FROM clanhall ORDER BY id"))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/CoupleManager.java

@@ -26,7 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Couple;
 import com.l2jserver.gameserver.model.entity.Couple;
@@ -53,7 +53,7 @@ public final class CoupleManager
 	
 	
 	private final void load()
 	private final void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement ps = con.createStatement();
 			Statement ps = con.createStatement();
 			ResultSet rs = ps.executeQuery("SELECT id FROM mods_wedding ORDER BY id"))
 			ResultSet rs = ps.executeQuery("SELECT id FROM mods_wedding ORDER BY id"))
 		{
 		{

+ 47 - 49
L2J_Server/java/com/l2jserver/gameserver/instancemanager/CursedWeaponsManager.java

@@ -38,7 +38,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.CursedWeapon;
 import com.l2jserver.gameserver.model.CursedWeapon;
 import com.l2jserver.gameserver.model.actor.L2Attackable;
 import com.l2jserver.gameserver.model.actor.L2Attackable;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -174,7 +174,7 @@ public final class CursedWeaponsManager
 	
 	
 	private final void restore()
 	private final void restore()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT itemId, charId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons"))
 			ResultSet rs = s.executeQuery("SELECT itemId, charId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons"))
 		{
 		{
@@ -199,64 +199,62 @@ public final class CursedWeaponsManager
 	
 	
 	private final void controlPlayers()
 	private final void controlPlayers()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		// TODO: See comments below...
+		// This entire for loop should NOT be necessary, since it is already handled by
+		// CursedWeapon.endOfLife(). However, if we indeed *need* to duplicate it for safety,
+		// then we'd better make sure that it FULLY cleans up inactive cursed weapons!
+		// Undesired effects result otherwise, such as player with no zariche but with karma
+		// or a lost-child entry in the cursed weapons table, without a corresponding one in items...
+		
+		// Retrieve the L2PcInstance from the characters table of the database
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
 		{
 		{
-			// TODO: See comments below...
-			// This entire for loop should NOT be necessary, since it is already handled by
-			// CursedWeapon.endOfLife(). However, if we indeed *need* to duplicate it for safety,
-			// then we'd better make sure that it FULLY cleans up inactive cursed weapons!
-			// Undesired effects result otherwise, such as player with no zariche but with karma
-			// or a lost-child entry in the cursed weapons table, without a corresponding one in items...
-			
-			// Retrieve the L2PcInstance from the characters table of the database
-			try (PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
+			for (CursedWeapon cw : _cursedWeapons.values())
 			{
 			{
-				for (CursedWeapon cw : _cursedWeapons.values())
+				if (cw.isActivated())
 				{
 				{
-					if (cw.isActivated())
-					{
-						continue;
-					}
-					
-					// Do an item check to be sure that the cursed weapon isn't hold by someone
-					int itemId = cw.getItemId();
-					ps.setInt(1, itemId);
-					try (ResultSet rset = ps.executeQuery())
+					continue;
+				}
+				
+				// Do an item check to be sure that the cursed weapon isn't hold by someone
+				int itemId = cw.getItemId();
+				ps.setInt(1, itemId);
+				try (ResultSet rset = ps.executeQuery())
+				{
+					if (rset.next())
 					{
 					{
-						if (rset.next())
+						// A player has the cursed weapon in his inventory ...
+						int playerId = rset.getInt("owner_id");
+						_log.info("PROBLEM : Player " + playerId + " owns the cursed weapon " + itemId + " but he shouldn't.");
+						
+						// Delete the item
+						try (PreparedStatement delete = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?"))
 						{
 						{
-							// A player has the cursed weapon in his inventory ...
-							int playerId = rset.getInt("owner_id");
-							_log.info("PROBLEM : Player " + playerId + " owns the cursed weapon " + itemId + " but he shouldn't.");
-							
-							// Delete the item
-							try (PreparedStatement delete = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?"))
+							delete.setInt(1, playerId);
+							delete.setInt(2, itemId);
+							if (delete.executeUpdate() != 1)
 							{
 							{
-								delete.setInt(1, playerId);
-								delete.setInt(2, itemId);
-								if (delete.executeUpdate() != 1)
-								{
-									_log.warning("Error while deleting cursed weapon " + itemId + " from userId " + playerId);
-								}
+								_log.warning("Error while deleting cursed weapon " + itemId + " from userId " + playerId);
 							}
 							}
-							
-							// Restore the player's old karma and pk count
-							try (PreparedStatement update = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE charId=?"))
+						}
+						
+						// Restore the player's old karma and pk count
+						try (PreparedStatement update = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE charId=?"))
+						{
+							update.setInt(1, cw.getPlayerKarma());
+							update.setInt(2, cw.getPlayerPkKills());
+							update.setInt(3, playerId);
+							if (update.executeUpdate() != 1)
 							{
 							{
-								update.setInt(1, cw.getPlayerKarma());
-								update.setInt(2, cw.getPlayerPkKills());
-								update.setInt(3, playerId);
-								if (update.executeUpdate() != 1)
-								{
-									_log.warning("Error while updating karma & pkkills for userId " + cw.getPlayerId());
-								}
+								_log.warning("Error while updating karma & pkkills for userId " + cw.getPlayerId());
 							}
 							}
-							// clean up the cursed weapons table.
-							removeFromDb(itemId);
 						}
 						}
+						// clean up the cursed weapons table.
+						removeFromDb(itemId);
 					}
 					}
-					ps.clearParameters();
 				}
 				}
+				ps.clearParameters();
 			}
 			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
@@ -375,7 +373,7 @@ public final class CursedWeaponsManager
 	
 	
 	public static void removeFromDb(int itemId)
 	public static void removeFromDb(int itemId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?"))
 		{
 		{
 			ps.setInt(1, itemId);
 			ps.setInt(1, itemId);

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/DimensionalRiftManager.java

@@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.model.DimensionalRiftRoom;
 import com.l2jserver.gameserver.model.DimensionalRiftRoom;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.L2Spawn;
@@ -76,7 +76,7 @@ public final class DimensionalRiftManager
 	
 	
 	private void loadRooms()
 	private void loadRooms()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM dimensional_rift"))
 			ResultSet rs = s.executeQuery("SELECT * FROM dimensional_rift"))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/FortManager.java

@@ -26,7 +26,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.InstanceListManager;
 import com.l2jserver.gameserver.InstanceListManager;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Object;
@@ -162,7 +162,7 @@ public final class FortManager implements InstanceListManager
 	@Override
 	@Override
 	public void loadInstances()
 	public void loadInstances()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT id FROM fort ORDER BY id"))
 			ResultSet rs = s.executeQuery("SELECT id FROM fort ORDER BY id"))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/FortSiegeGuardManager.java

@@ -28,7 +28,7 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.entity.Fort;
 import com.l2jserver.gameserver.model.entity.Fort;
 
 
@@ -106,7 +106,7 @@ public final class FortSiegeGuardManager
 	void loadSiegeGuard()
 	void loadSiegeGuard()
 	{
 	{
 		_siegeGuards.clear();
 		_siegeGuards.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT npcId, x, y, z, heading, respawnDelay FROM fort_siege_guards WHERE fortId = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT npcId, x, y, z, heading, respawnDelay FROM fort_siege_guards WHERE fortId = ?"))
 		{
 		{
 			final int fortId = getFort().getResidenceId();
 			final int fortId = getFort().getResidenceId();

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/FortSiegeManager.java

@@ -34,7 +34,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.CombatFlag;
 import com.l2jserver.gameserver.model.CombatFlag;
 import com.l2jserver.gameserver.model.FortSiegeSpawn;
 import com.l2jserver.gameserver.model.FortSiegeSpawn;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
@@ -88,7 +88,7 @@ public final class FortSiegeManager
 		}
 		}
 		
 		
 		boolean register = false;
 		boolean register = false;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans where clan_id=? and fort_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans where clan_id=? and fort_id=?"))
 		{
 		{
 			ps.setInt(1, clan.getId());
 			ps.setInt(1, clan.getId());

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/instancemanager/FourSepulchersManager.java

@@ -35,7 +35,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.xml.impl.DoorData;
 import com.l2jserver.gameserver.data.xml.impl.DoorData;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.datatables.SpawnTable;
@@ -406,7 +406,7 @@ public final class FourSepulchersManager
 	{
 	{
 		_mysteriousBoxSpawns.clear();
 		_mysteriousBoxSpawns.clear();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY id"))
 			PreparedStatement ps = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY id"))
 		{
 		{
 			ps.setInt(1, 0);
 			ps.setInt(1, 0);
@@ -463,7 +463,7 @@ public final class FourSepulchersManager
 		_physicalMonsters.clear();
 		_physicalMonsters.clear();
 		
 		
 		int loaded = 0;
 		int loaded = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 		{
 		{
 			ps1.setInt(1, 1);
 			ps1.setInt(1, 1);
@@ -510,7 +510,7 @@ public final class FourSepulchersManager
 		_magicalMonsters.clear();
 		_magicalMonsters.clear();
 		
 		
 		int loaded = 0;
 		int loaded = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 		{
 		{
 			ps1.setInt(1, 2);
 			ps1.setInt(1, 2);
@@ -559,7 +559,7 @@ public final class FourSepulchersManager
 		_archonSpawned.clear();
 		_archonSpawned.clear();
 		
 		
 		int loaded = 0;
 		int loaded = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 		{
 		{
 			ps1.setInt(1, 5);
 			ps1.setInt(1, 5);
@@ -610,7 +610,7 @@ public final class FourSepulchersManager
 		_emperorsGraveNpcs.clear();
 		_emperorsGraveNpcs.clear();
 		
 		
 		int loaded = 0;
 		int loaded = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 			PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
 		{
 		{
 			ps1.setInt(1, 6);
 			ps1.setInt(1, 6);

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/instancemanager/GlobalVariablesManager.java

@@ -27,7 +27,7 @@ import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.variables.AbstractVariables;
 import com.l2jserver.gameserver.model.variables.AbstractVariables;
 
 
 /**
 /**
@@ -52,7 +52,7 @@ public final class GlobalVariablesManager extends AbstractVariables
 	public boolean restoreMe()
 	public boolean restoreMe()
 	{
 	{
 		// Restore previous variables.
 		// Restore previous variables.
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement st = con.createStatement();
 			Statement st = con.createStatement();
 			ResultSet rset = st.executeQuery(SELECT_QUERY))
 			ResultSet rset = st.executeQuery(SELECT_QUERY))
 		{
 		{
@@ -83,7 +83,7 @@ public final class GlobalVariablesManager extends AbstractVariables
 			return false;
 			return false;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement del = con.createStatement();
 			Statement del = con.createStatement();
 			PreparedStatement st = con.prepareStatement(INSERT_QUERY))
 			PreparedStatement st = con.prepareStatement(INSERT_QUERY))
 		{
 		{

+ 7 - 7
L2J_Server/java/com/l2jserver/gameserver/instancemanager/GrandBossManager.java

@@ -34,7 +34,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.instancemanager.tasks.GrandBossManagerStoreTask;
 import com.l2jserver.gameserver.instancemanager.tasks.GrandBossManagerStoreTask;
@@ -76,7 +76,7 @@ public final class GrandBossManager implements IStorable
 	
 	
 	private void init()
 	private void init()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
 			ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
 		{
 		{
@@ -141,7 +141,7 @@ public final class GrandBossManager implements IStorable
 			zones.put(zone.getId(), new ArrayList<>());
 			zones.put(zone.getId(), new ArrayList<>());
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * from grandboss_list ORDER BY player_id"))
 			ResultSet rs = s.executeQuery("SELECT * from grandboss_list ORDER BY player_id"))
 		{
 		{
@@ -301,10 +301,10 @@ public final class GrandBossManager implements IStorable
 	@Override
 	@Override
 	public boolean storeMe()
 	public boolean storeMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement delete = con.prepareStatement(DELETE_GRAND_BOSS_LIST))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement())
 		{
 		{
-			delete.executeUpdate();
+			s.executeUpdate(DELETE_GRAND_BOSS_LIST);
 			
 			
 			try (PreparedStatement insert = con.prepareStatement(INSERT_GRAND_BOSS_LIST))
 			try (PreparedStatement insert = con.prepareStatement(INSERT_GRAND_BOSS_LIST))
 			{
 			{
@@ -379,7 +379,7 @@ public final class GrandBossManager implements IStorable
 	
 	
 	private void updateDb(int bossId, boolean statusOnly)
 	private void updateDb(int bossId, boolean statusOnly)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			L2GrandBossInstance boss = BOSSES.get(bossId);
 			L2GrandBossInstance boss = BOSSES.get(bossId);
 			StatsSet info = _storedInfo.get(bossId);
 			StatsSet info = _storedInfo.get(bossId);

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/instancemanager/InstanceManager.java

@@ -29,7 +29,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Instance;
 import com.l2jserver.gameserver.model.entity.Instance;
 import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
 import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
@@ -113,7 +113,7 @@ public final class InstanceManager implements IXmlReader
 			restoreInstanceTimes(playerObjId);
 			restoreInstanceTimes(playerObjId);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(ADD_INSTANCE_TIME))
 			PreparedStatement ps = con.prepareStatement(ADD_INSTANCE_TIME))
 		{
 		{
 			ps.setInt(1, playerObjId);
 			ps.setInt(1, playerObjId);
@@ -135,7 +135,7 @@ public final class InstanceManager implements IXmlReader
 	 */
 	 */
 	public void deleteInstanceTime(int playerObjId, int id)
 	public void deleteInstanceTime(int playerObjId, int id)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
 			PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
 		{
 		{
 			ps.setInt(1, playerObjId);
 			ps.setInt(1, playerObjId);
@@ -159,7 +159,7 @@ public final class InstanceManager implements IXmlReader
 			return; // already restored
 			return; // already restored
 		}
 		}
 		_playerInstanceTimes.put(playerObjId, new ConcurrentHashMap<>());
 		_playerInstanceTimes.put(playerObjId, new ConcurrentHashMap<>());
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(RESTORE_INSTANCE_TIMES))
 			PreparedStatement ps = con.prepareStatement(RESTORE_INSTANCE_TIMES))
 		{
 		{
 			ps.setInt(1, playerObjId);
 			ps.setInt(1, playerObjId);

+ 13 - 13
L2J_Server/java/com/l2jserver/gameserver/instancemanager/ItemAuctionManager.java

@@ -37,7 +37,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.itemauction.ItemAuctionInstance;
 import com.l2jserver.gameserver.model.itemauction.ItemAuctionInstance;
 
 
 /**
 /**
@@ -60,13 +60,13 @@ public final class ItemAuctionManager
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			Statement statement = con.createStatement();
-			ResultSet rset = statement.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement();
+			ResultSet rs = s.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1"))
 		{
 		{
-			if (rset.next())
+			if (rs.next())
 			{
 			{
-				_auctionIds.set(rset.getInt(1) + 1);
+				_auctionIds.set(rs.getInt(1) + 1);
 			}
 			}
 		}
 		}
 		catch (final SQLException e)
 		catch (final SQLException e)
@@ -138,18 +138,18 @@ public final class ItemAuctionManager
 	
 	
 	public static final void deleteAuction(final int auctionId)
 	public static final void deleteAuction(final int auctionId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
-			try (PreparedStatement statement = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?"))
+			try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?"))
 			{
 			{
-				statement.setInt(1, auctionId);
-				statement.execute();
+				ps.setInt(1, auctionId);
+				ps.execute();
 			}
 			}
 			
 			
-			try (PreparedStatement statement = con.prepareStatement("DELETE FROM item_auction_bid WHERE auctionId=?"))
+			try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_auction_bid WHERE auctionId=?"))
 			{
 			{
-				statement.setInt(1, auctionId);
-				statement.execute();
+				ps.setInt(1, auctionId);
+				ps.execute();
 			}
 			}
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)

+ 17 - 17
L2J_Server/java/com/l2jserver/gameserver/instancemanager/ItemsOnGroundManager.java

@@ -29,7 +29,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ItemsAutoDestroy;
 import com.l2jserver.gameserver.ItemsAutoDestroy;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
@@ -82,7 +82,7 @@ public final class ItemsOnGroundManager implements Runnable
 				str = "UPDATE itemsonground SET drop_time = ? WHERE drop_time = -1";
 				str = "UPDATE itemsonground SET drop_time = ? WHERE drop_time = -1";
 			}
 			}
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement(str))
 				PreparedStatement ps = con.prepareStatement(str))
 			{
 			{
 				ps.setLong(1, System.currentTimeMillis());
 				ps.setLong(1, System.currentTimeMillis());
@@ -95,7 +95,7 @@ public final class ItemsOnGroundManager implements Runnable
 		}
 		}
 		
 		
 		// Add items to world
 		// Add items to world
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable FROM itemsonground"))
 			PreparedStatement ps = con.prepareStatement("SELECT object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable FROM itemsonground"))
 		{
 		{
 			int count = 0;
 			int count = 0;
@@ -181,7 +181,7 @@ public final class ItemsOnGroundManager implements Runnable
 	
 	
 	public void emptyTable()
 	public void emptyTable()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement())
 			Statement s = con.createStatement())
 		{
 		{
 			s.executeUpdate("DELETE FROM itemsonground");
 			s.executeUpdate("DELETE FROM itemsonground");
@@ -207,8 +207,8 @@ public final class ItemsOnGroundManager implements Runnable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)"))
 		{
 		{
 			for (L2ItemInstance item : _items)
 			for (L2ItemInstance item : _items)
 			{
 			{
@@ -224,17 +224,17 @@ public final class ItemsOnGroundManager implements Runnable
 				
 				
 				try
 				try
 				{
 				{
-					statement.setInt(1, item.getObjectId());
-					statement.setInt(2, item.getId());
-					statement.setLong(3, item.getCount());
-					statement.setInt(4, item.getEnchantLevel());
-					statement.setInt(5, item.getX());
-					statement.setInt(6, item.getY());
-					statement.setInt(7, item.getZ());
-					statement.setLong(8, (item.isProtected() ? -1 : item.getDropTime())); // item is protected or AutoDestroyed
-					statement.setLong(9, (item.isEquipable() ? 1 : 0)); // set equip-able
-					statement.execute();
-					statement.clearParameters();
+					ps.setInt(1, item.getObjectId());
+					ps.setInt(2, item.getId());
+					ps.setLong(3, item.getCount());
+					ps.setInt(4, item.getEnchantLevel());
+					ps.setInt(5, item.getX());
+					ps.setInt(6, item.getY());
+					ps.setInt(7, item.getZ());
+					ps.setLong(8, (item.isProtected() ? -1 : item.getDropTime())); // item is protected or AutoDestroyed
+					ps.setLong(9, (item.isEquipable() ? 1 : 0)); // set equip-able
+					ps.execute();
+					ps.clearParameters();
 				}
 				}
 				catch (Exception e)
 				catch (Exception e)
 				{
 				{

+ 8 - 8
L2J_Server/java/com/l2jserver/gameserver/instancemanager/MailManager.java

@@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.instancemanager.tasks.MessageDeletionTask;
 import com.l2jserver.gameserver.instancemanager.tasks.MessageDeletionTask;
@@ -57,7 +57,7 @@ public final class MailManager
 	private void load()
 	private void load()
 	{
 	{
 		int count = 0;
 		int count = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement ps = con.createStatement();
 			Statement ps = con.createStatement();
 			ResultSet rs = ps.executeQuery("SELECT * FROM messages ORDER BY expiration"))
 			ResultSet rs = ps.executeQuery("SELECT * FROM messages ORDER BY expiration"))
 		{
 		{
@@ -168,7 +168,7 @@ public final class MailManager
 	public void sendMessage(Message msg)
 	public void sendMessage(Message msg)
 	{
 	{
 		_messages.put(msg.getId(), msg);
 		_messages.put(msg.getId(), msg);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = Message.getStatement(msg, con))
 			PreparedStatement ps = Message.getStatement(msg, con))
 		{
 		{
 			ps.execute();
 			ps.execute();
@@ -189,7 +189,7 @@ public final class MailManager
 	
 	
 	public final void markAsReadInDb(int msgId)
 	public final void markAsReadInDb(int msgId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET isUnread = 'false' WHERE messageId = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET isUnread = 'false' WHERE messageId = ?"))
 		{
 		{
 			ps.setInt(1, msgId);
 			ps.setInt(1, msgId);
@@ -203,7 +203,7 @@ public final class MailManager
 	
 	
 	public final void markAsDeletedBySenderInDb(int msgId)
 	public final void markAsDeletedBySenderInDb(int msgId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET isDeletedBySender = 'true' WHERE messageId = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET isDeletedBySender = 'true' WHERE messageId = ?"))
 		{
 		{
 			ps.setInt(1, msgId);
 			ps.setInt(1, msgId);
@@ -217,7 +217,7 @@ public final class MailManager
 	
 	
 	public final void markAsDeletedByReceiverInDb(int msgId)
 	public final void markAsDeletedByReceiverInDb(int msgId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET isDeletedByReceiver = 'true' WHERE messageId = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET isDeletedByReceiver = 'true' WHERE messageId = ?"))
 		{
 		{
 			ps.setInt(1, msgId);
 			ps.setInt(1, msgId);
@@ -231,7 +231,7 @@ public final class MailManager
 	
 	
 	public final void removeAttachmentsInDb(int msgId)
 	public final void removeAttachmentsInDb(int msgId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET hasAttachments = 'false' WHERE messageId = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE messages SET hasAttachments = 'false' WHERE messageId = ?"))
 		{
 		{
 			ps.setInt(1, msgId);
 			ps.setInt(1, msgId);
@@ -245,7 +245,7 @@ public final class MailManager
 	
 	
 	public final void deleteMessageInDb(int msgId)
 	public final void deleteMessageInDb(int msgId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM messages WHERE messageId = ?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM messages WHERE messageId = ?"))
 		{
 		{
 			ps.setInt(1, msgId);
 			ps.setInt(1, msgId);

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/MercTicketManager.java

@@ -26,7 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.data.xml.impl.NpcData;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
@@ -147,7 +147,7 @@ public final class MercTicketManager
 	 */
 	 */
 	private final void load()
 	private final void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1"))
 			ResultSet rs = s.executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1"))
 		{
 		{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/instancemanager/PunishmentManager.java

@@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.holders.PunishmentHolder;
 import com.l2jserver.gameserver.model.holders.PunishmentHolder;
 import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
 import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
 import com.l2jserver.gameserver.model.punishment.PunishmentTask;
 import com.l2jserver.gameserver.model.punishment.PunishmentTask;
@@ -58,7 +58,7 @@ public final class PunishmentManager
 		int expired = 0;
 		int expired = 0;
 		
 		
 		// Load punishments.
 		// Load punishments.
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement st = con.createStatement();
 			Statement st = con.createStatement();
 			ResultSet rset = st.executeQuery("SELECT * FROM punishments"))
 			ResultSet rset = st.executeQuery("SELECT * FROM punishments"))
 		{
 		{

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/instancemanager/RaidBossPointsManager.java

@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
 /**
 /**
@@ -53,7 +53,7 @@ public class RaidBossPointsManager
 	
 	
 	private final void init()
 	private final void init()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT `charId`,`boss_id`,`points` FROM `character_raid_points`"))
 			ResultSet rs = s.executeQuery("SELECT `charId`,`boss_id`,`points` FROM `character_raid_points`"))
 		{
 		{
@@ -80,7 +80,7 @@ public class RaidBossPointsManager
 	
 	
 	public final void updatePointsInDB(L2PcInstance player, int raidId, int points)
 	public final void updatePointsInDB(L2PcInstance player, int raidId, int points)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("REPLACE INTO character_raid_points (`charId`,`boss_id`,`points`) VALUES (?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("REPLACE INTO character_raid_points (`charId`,`boss_id`,`points`) VALUES (?,?,?)"))
 		{
 		{
 			ps.setInt(1, player.getObjectId());
 			ps.setInt(1, player.getObjectId());
@@ -124,10 +124,10 @@ public class RaidBossPointsManager
 	
 	
 	public final void cleanUp()
 	public final void cleanUp()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE from character_raid_points WHERE charId > 0"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement())
 		{
 		{
-			statement.executeUpdate();
+			s.executeUpdate("DELETE from character_raid_points WHERE charId > 0");
 			_list.clear();
 			_list.clear();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)

+ 39 - 37
L2J_Server/java/com/l2jserver/gameserver/instancemanager/RaidBossSpawnManager.java

@@ -22,6 +22,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -30,7 +31,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.L2Spawn;
@@ -76,21 +77,21 @@ public class RaidBossSpawnManager
 		_storedInfo.clear();
 		_storedInfo.clear();
 		_schedules.clear();
 		_schedules.clear();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT * FROM raidboss_spawnlist ORDER BY boss_id");
-			ResultSet rset = statement.executeQuery())
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement();
+			ResultSet rs = s.executeQuery("SELECT * FROM raidboss_spawnlist ORDER BY boss_id"))
 		{
 		{
-			while (rset.next())
+			while (rs.next())
 			{
 			{
-				final L2Spawn spawnDat = new L2Spawn(rset.getInt("boss_id"));
-				spawnDat.setX(rset.getInt("loc_x"));
-				spawnDat.setY(rset.getInt("loc_y"));
-				spawnDat.setZ(rset.getInt("loc_z"));
-				spawnDat.setAmount(rset.getInt("amount"));
-				spawnDat.setHeading(rset.getInt("heading"));
-				spawnDat.setRespawnDelay(rset.getInt("respawn_delay"), rset.getInt("respawn_random"));
+				final L2Spawn spawnDat = new L2Spawn(rs.getInt("boss_id"));
+				spawnDat.setX(rs.getInt("loc_x"));
+				spawnDat.setY(rs.getInt("loc_y"));
+				spawnDat.setZ(rs.getInt("loc_z"));
+				spawnDat.setAmount(rs.getInt("amount"));
+				spawnDat.setHeading(rs.getInt("heading"));
+				spawnDat.setRespawnDelay(rs.getInt("respawn_delay"), rs.getInt("respawn_random"));
 				
 				
-				addNewSpawn(spawnDat, rset.getLong("respawn_time"), rset.getDouble("currentHP"), rset.getDouble("currentMP"), false);
+				addNewSpawn(spawnDat, rs.getLong("respawn_time"), rs.getDouble("currentHP"), rs.getDouble("currentMP"), false);
 			}
 			}
 			
 			
 			_log.info(getClass().getSimpleName() + ": Loaded " + _bosses.size() + " Instances");
 			_log.info(getClass().getSimpleName() + ": Loaded " + _bosses.size() + " Instances");
@@ -265,19 +266,19 @@ public class RaidBossSpawnManager
 		
 		
 		if (storeInDb)
 		if (storeInDb)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
 			{
 			{
-				statement.setInt(1, spawnDat.getId());
-				statement.setInt(2, spawnDat.getAmount());
-				statement.setInt(3, spawnDat.getX());
-				statement.setInt(4, spawnDat.getY());
-				statement.setInt(5, spawnDat.getZ());
-				statement.setInt(6, spawnDat.getHeading());
-				statement.setLong(7, respawnTime);
-				statement.setDouble(8, currentHP);
-				statement.setDouble(9, currentMP);
-				statement.execute();
+				ps.setInt(1, spawnDat.getId());
+				ps.setInt(2, spawnDat.getAmount());
+				ps.setInt(3, spawnDat.getX());
+				ps.setInt(4, spawnDat.getY());
+				ps.setInt(5, spawnDat.getZ());
+				ps.setInt(6, spawnDat.getHeading());
+				ps.setLong(7, respawnTime);
+				ps.setDouble(8, currentHP);
+				ps.setDouble(9, currentMP);
+				ps.execute();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -326,11 +327,11 @@ public class RaidBossSpawnManager
 		
 		
 		if (updateDb)
 		if (updateDb)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?"))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?"))
 			{
 			{
-				statement.setInt(1, bossId);
-				statement.execute();
+				ps.setInt(1, bossId);
+				ps.execute();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -345,8 +346,8 @@ public class RaidBossSpawnManager
 	 */
 	 */
 	private void updateDb()
 	private void updateDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?"))
 		{
 		{
 			for (Integer bossId : _storedInfo.keySet())
 			for (Integer bossId : _storedInfo.keySet())
 			{
 			{
@@ -376,12 +377,13 @@ public class RaidBossSpawnManager
 				
 				
 				try
 				try
 				{
 				{
-					statement.setLong(1, info.getLong("respawnTime"));
-					statement.setDouble(2, info.getDouble("currentHP"));
-					statement.setDouble(3, info.getDouble("currentMP"));
-					statement.setInt(4, bossId);
-					statement.executeUpdate();
-					statement.clearParameters();
+					// TODO(Zoey76): Change this to use batch.
+					ps.setLong(1, info.getLong("respawnTime"));
+					ps.setDouble(2, info.getDouble("currentHP"));
+					ps.setDouble(3, info.getDouble("currentMP"));
+					ps.setInt(4, bossId);
+					ps.executeUpdate();
+					ps.clearParameters();
 				}
 				}
 				catch (SQLException e)
 				catch (SQLException e)
 				{
 				{

+ 15 - 15
L2J_Server/java/com/l2jserver/gameserver/instancemanager/SiegeGuardManager.java

@@ -26,7 +26,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Castle;
 import com.l2jserver.gameserver.model.entity.Castle;
@@ -106,7 +106,7 @@ public final class SiegeGuardManager
 	 */
 	 */
 	public void removeMerc(int npcId, int x, int y, int z)
 	public void removeMerc(int npcId, int x, int y, int z)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("Delete From castle_siege_guards Where npcId = ? And x = ? AND y = ? AND z = ? AND isHired = 1"))
 			PreparedStatement ps = con.prepareStatement("Delete From castle_siege_guards Where npcId = ? And x = ? AND y = ? AND z = ? AND isHired = 1"))
 		{
 		{
 			ps.setInt(1, npcId);
 			ps.setInt(1, npcId);
@@ -126,7 +126,7 @@ public final class SiegeGuardManager
 	 */
 	 */
 	public void removeMercs()
 	public void removeMercs()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("Delete From castle_siege_guards Where castleId = ? And isHired = 1"))
 			PreparedStatement ps = con.prepareStatement("Delete From castle_siege_guards Where castleId = ? And isHired = 1"))
 		{
 		{
 			ps.setInt(1, getCastle().getResidenceId());
 			ps.setInt(1, getCastle().getResidenceId());
@@ -192,7 +192,7 @@ public final class SiegeGuardManager
 	 */
 	 */
 	private void loadSiegeGuard()
 	private void loadSiegeGuard()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_siege_guards Where castleId = ? And isHired = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_siege_guards Where castleId = ? And isHired = ?"))
 		{
 		{
 			ps.setInt(1, getCastle().getResidenceId());
 			ps.setInt(1, getCastle().getResidenceId());
@@ -238,18 +238,18 @@ public final class SiegeGuardManager
 	 */
 	 */
 	private void saveSiegeGuard(int x, int y, int z, int heading, int npcId, int isHire)
 	private void saveSiegeGuard(int x, int y, int z, int heading, int npcId, int isHire)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)"))
 		{
 		{
-			statement.setInt(1, getCastle().getResidenceId());
-			statement.setInt(2, npcId);
-			statement.setInt(3, x);
-			statement.setInt(4, y);
-			statement.setInt(5, z);
-			statement.setInt(6, heading);
-			statement.setInt(7, (isHire == 1 ? 0 : 600));
-			statement.setInt(8, isHire);
-			statement.execute();
+			ps.setInt(1, getCastle().getResidenceId());
+			ps.setInt(2, npcId);
+			ps.setInt(3, x);
+			ps.setInt(4, y);
+			ps.setInt(5, z);
+			ps.setInt(6, heading);
+			ps.setInt(7, (isHire == 1 ? 0 : 600));
+			ps.setInt(8, isHire);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 7 - 7
L2J_Server/java/com/l2jserver/gameserver/instancemanager/SiegeManager.java

@@ -30,7 +30,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Object;
@@ -89,12 +89,12 @@ public final class SiegeManager
 		}
 		}
 		
 		
 		boolean register = false;
 		boolean register = false;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?"))
 		{
 		{
-			statement.setInt(1, clan.getId());
-			statement.setInt(2, castleid);
-			try (ResultSet rs = statement.executeQuery())
+			ps.setInt(1, clan.getId());
+			ps.setInt(2, castleid);
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				while (rs.next())
 				while (rs.next())
 				{
 				{
@@ -278,7 +278,7 @@ public final class SiegeManager
 	
 	
 	private final void loadTrapUpgrade(int castleId)
 	private final void loadTrapUpgrade(int castleId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_trapupgrade WHERE castleId=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_trapupgrade WHERE castleId=?"))
 		{
 		{
 			ps.setInt(1, castleId);
 			ps.setInt(1, castleId);

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/instancemanager/TerritoryWarManager.java

@@ -34,7 +34,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
 import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
@@ -753,7 +753,7 @@ public final class TerritoryWarManager implements Siegable
 	private void changeRegistration(int castleId, int objId, boolean delete)
 	private void changeRegistration(int castleId, int objId, boolean delete)
 	{
 	{
 		final String query = delete ? DELETE : INSERT;
 		final String query = delete ? DELETE : INSERT;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(query))
 			PreparedStatement ps = con.prepareStatement(query))
 		{
 		{
 			ps.setInt(1, castleId);
 			ps.setInt(1, castleId);
@@ -774,7 +774,7 @@ public final class TerritoryWarManager implements Siegable
 			wardList.append(i + ";");
 			wardList.append(i + ";");
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE territories SET ownedWardIds=? WHERE territoryId=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE territories SET ownedWardIds=? WHERE territoryId=?"))
 		{
 		{
 			ps.setString(1, wardList.toString());
 			ps.setString(1, wardList.toString());
@@ -804,7 +804,7 @@ public final class TerritoryWarManager implements Siegable
 		MINTWBADGEFORSTRIDERS = territoryWarSettings.getInt("MinTerritoryBadgeForStriders", 50);
 		MINTWBADGEFORSTRIDERS = territoryWarSettings.getInt("MinTerritoryBadgeForStriders", 50);
 		MINTWBADGEFORBIGSTRIDER = territoryWarSettings.getInt("MinTerritoryBadgeForBigStrider", 80);
 		MINTWBADGEFORBIGSTRIDER = territoryWarSettings.getInt("MinTerritoryBadgeForBigStrider", 80);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM territory_spawnlist"))
 			ResultSet rs = s.executeQuery("SELECT * FROM territory_spawnlist"))
 		{
 		{
@@ -838,7 +838,7 @@ public final class TerritoryWarManager implements Siegable
 			_log.log(Level.WARNING, getClass().getSimpleName() + ": SpawnList error: " + e.getMessage(), e);
 			_log.log(Level.WARNING, getClass().getSimpleName() + ": SpawnList error: " + e.getMessage(), e);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM territories"))
 			ResultSet rs = s.executeQuery("SELECT * FROM territories"))
 		{
 		{
@@ -876,7 +876,7 @@ public final class TerritoryWarManager implements Siegable
 			_log.log(Level.WARNING, getClass().getSimpleName() + ": territory list error(): " + e.getMessage(), e);
 			_log.log(Level.WARNING, getClass().getSimpleName() + ": territory list error(): " + e.getMessage(), e);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM territory_registrations"))
 			ResultSet rs = s.executeQuery("SELECT * FROM territory_registrations"))
 		{
 		{

+ 41 - 41
L2J_Server/java/com/l2jserver/gameserver/instancemanager/games/Lottery.java

@@ -28,7 +28,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.SystemMessageId;
@@ -93,13 +93,13 @@ public class Lottery
 	public void increasePrize(long count)
 	public void increasePrize(long count)
 	{
 	{
 		_prize += count;
 		_prize += count;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(UPDATE_PRICE))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(UPDATE_PRICE))
 		{
 		{
-			statement.setLong(1, getPrize());
-			statement.setLong(2, getPrize());
-			statement.setInt(3, getId());
-			statement.execute();
+			ps.setLong(1, getPrize());
+			ps.setLong(2, getPrize());
+			ps.setInt(3, getId());
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -128,7 +128,7 @@ public class Lottery
 		public void run()
 		public void run()
 		{
 		{
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				Statement statement = con.createStatement();
 				Statement statement = con.createStatement();
 				ResultSet rset = statement.executeQuery(SELECT_LAST_LOTTERY))
 				ResultSet rset = statement.executeQuery(SELECT_LAST_LOTTERY))
 			{
 			{
@@ -201,15 +201,15 @@ public class Lottery
 			ThreadPoolManager.getInstance().scheduleGeneral(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
 			ThreadPoolManager.getInstance().scheduleGeneral(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
 			ThreadPoolManager.getInstance().scheduleGeneral(new finishLottery(), _enddate - System.currentTimeMillis());
 			ThreadPoolManager.getInstance().scheduleGeneral(new finishLottery(), _enddate - System.currentTimeMillis());
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(INSERT_LOTTERY))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(INSERT_LOTTERY))
 			{
 			{
-				statement.setInt(1, 1);
-				statement.setInt(2, getId());
-				statement.setLong(3, getEndDate());
-				statement.setLong(4, getPrize());
-				statement.setLong(5, getPrize());
-				statement.execute();
+				ps.setInt(1, 1);
+				ps.setInt(2, getId());
+				ps.setLong(3, getEndDate());
+				ps.setLong(4, getPrize());
+				ps.setLong(5, getPrize());
+				ps.execute();
 			}
 			}
 			catch (SQLException e)
 			catch (SQLException e)
 			{
 			{
@@ -307,11 +307,11 @@ public class Lottery
 			int count3 = 0;
 			int count3 = 0;
 			int count4 = 0;
 			int count4 = 0;
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(SELECT_LOTTERY_ITEM))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_ITEM))
 			{
 			{
-				statement.setInt(1, getId());
-				try (ResultSet rset = statement.executeQuery())
+				ps.setInt(1, getId());
+				try (ResultSet rset = ps.executeQuery())
 				{
 				{
 					while (rset.next())
 					while (rset.next())
 					{
 					{
@@ -422,18 +422,18 @@ public class Lottery
 				Broadcast.toAllOnlinePlayers(sm);
 				Broadcast.toAllOnlinePlayers(sm);
 			}
 			}
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(UPDATE_LOTTERY))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(UPDATE_LOTTERY))
 			{
 			{
-				statement.setLong(1, getPrize());
-				statement.setLong(2, newprize);
-				statement.setInt(3, enchant);
-				statement.setInt(4, type2);
-				statement.setLong(5, prize1);
-				statement.setLong(6, prize2);
-				statement.setLong(7, prize3);
-				statement.setInt(8, getId());
-				statement.execute();
+				ps.setLong(1, getPrize());
+				ps.setLong(2, newprize);
+				ps.setInt(3, enchant);
+				ps.setInt(4, type2);
+				ps.setLong(5, prize1);
+				ps.setLong(6, prize2);
+				ps.setLong(7, prize3);
+				ps.setInt(8, getId());
+				ps.execute();
 			}
 			}
 			catch (SQLException e)
 			catch (SQLException e)
 			{
 			{
@@ -492,16 +492,16 @@ public class Lottery
 			0,
 			0,
 			0
 			0
 		};
 		};
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(SELECT_LOTTERY_TICKET))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_TICKET))
 		{
 		{
-			statement.setInt(1, id);
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, id);
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				if (rset.next())
+				if (rs.next())
 				{
 				{
-					int curenchant = rset.getInt("number1") & enchant;
-					int curtype2 = rset.getInt("number2") & type2;
+					int curenchant = rs.getInt("number1") & enchant;
+					int curtype2 = rs.getInt("number2") & type2;
 					
 					
 					if ((curenchant == 0) && (curtype2 == 0))
 					if ((curenchant == 0) && (curtype2 == 0))
 					{
 					{
@@ -532,15 +532,15 @@ public class Lottery
 							break;
 							break;
 						case 5:
 						case 5:
 							res[0] = 1;
 							res[0] = 1;
-							res[1] = rset.getLong("prize1");
+							res[1] = rs.getLong("prize1");
 							break;
 							break;
 						case 4:
 						case 4:
 							res[0] = 2;
 							res[0] = 2;
-							res[1] = rset.getLong("prize2");
+							res[1] = rs.getLong("prize2");
 							break;
 							break;
 						case 3:
 						case 3:
 							res[0] = 3;
 							res[0] = 3;
-							res[1] = rset.getLong("prize3");
+							res[1] = rs.getLong("prize3");
 							break;
 							break;
 						default:
 						default:
 							res[0] = 4;
 							res[0] = 4;

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/model/AutoSpawnHandler.java

@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
@@ -118,7 +118,7 @@ public class AutoSpawnHandler
 	
 	
 	private void restoreSpawnData()
 	private void restoreSpawnData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s = con.createStatement();
 			Statement s = con.createStatement();
 			ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
 			ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))

+ 31 - 31
L2J_Server/java/com/l2jserver/gameserver/model/BlockList.java

@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.SystemMessageId;
@@ -55,13 +55,13 @@ public class BlockList
 	private void addToBlockList(int target)
 	private void addToBlockList(int target)
 	{
 	{
 		_blockList.add(target);
 		_blockList.add(target);
-		updateInDB(target, true);
+		persistInDB(target);
 	}
 	}
 	
 	
 	private void removeFromBlockList(int target)
 	private void removeFromBlockList(int target)
 	{
 	{
 		_blockList.remove(Integer.valueOf(target));
 		_blockList.remove(Integer.valueOf(target));
-		updateInDB(target, false);
+		removeFromDB(target);
 	}
 	}
 	
 	
 	public void playerLogout()
 	public void playerLogout()
@@ -72,16 +72,16 @@ public class BlockList
 	private static List<Integer> loadList(int ObjId)
 	private static List<Integer> loadList(int ObjId)
 	{
 	{
 		List<Integer> list = new ArrayList<>();
 		List<Integer> list = new ArrayList<>();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1"))
 		{
 		{
-			statement.setInt(1, ObjId);
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, ObjId);
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				int friendId;
 				int friendId;
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					friendId = rset.getInt("friendId");
+					friendId = rs.getInt("friendId");
 					if (friendId == ObjId)
 					if (friendId == ObjId)
 					{
 					{
 						continue;
 						continue;
@@ -97,33 +97,33 @@ public class BlockList
 		return list;
 		return list;
 	}
 	}
 	
 	
-	private void updateInDB(int targetId, boolean state)
+	private void removeFromDB(int targetId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
 		{
 		{
-			if (state) // add
-			{
-				try (PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
-				{
-					statement.setInt(1, _owner.getObjectId());
-					statement.setInt(2, targetId);
-					statement.execute();
-				}
-			}
-			else
-			// remove
-			{
-				try (PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
-				{
-					statement.setInt(1, _owner.getObjectId());
-					statement.setInt(2, targetId);
-					statement.execute();
-				}
-			}
+			ps.setInt(1, _owner.getObjectId());
+			ps.setInt(2, targetId);
+			ps.execute();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.WARNING, "Could not remove blocked player: " + e.getMessage(), e);
+		}
+	}
+	
+	private void persistInDB(int targetId)
+	{
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
+		{
+			ps.setInt(1, _owner.getObjectId());
+			ps.setInt(2, targetId);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
-			_log.log(Level.WARNING, "Could not add block player: " + e.getMessage(), e);
+			_log.log(Level.WARNING, "Could not add blocked player: " + e.getMessage(), e);
 		}
 		}
 	}
 	}
 	
 	

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/model/CursedWeapon.java

@@ -26,7 +26,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.xml.impl.TransformData;
 import com.l2jserver.gameserver.data.xml.impl.TransformData;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.datatables.SkillData;
@@ -140,7 +140,7 @@ public class CursedWeapon implements INamable
 				// Remove from Db
 				// Remove from Db
 				_log.info(_name + " being removed offline.");
 				_log.info(_name + " being removed offline.");
 				
 				
-				try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+				try (Connection con = ConnectionFactory.getInstance().getConnection();
 					PreparedStatement del = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
 					PreparedStatement del = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
 					PreparedStatement ps = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE charId=?"))
 					PreparedStatement ps = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE charId=?"))
 				{
 				{
@@ -486,7 +486,7 @@ public class CursedWeapon implements INamable
 			_log.info("CursedWeapon: Saving data to disk.");
 			_log.info("CursedWeapon: Saving data to disk.");
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement del = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
 			PreparedStatement del = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
 			PreparedStatement ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerKarma, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerKarma, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
 		{
 		{

+ 29 - 29
L2J_Server/java/com/l2jserver/gameserver/model/L2Clan.java

@@ -35,7 +35,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.communitybbs.BB.Forum;
 import com.l2jserver.gameserver.communitybbs.BB.Forum;
 import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
 import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
@@ -250,7 +250,7 @@ public class L2Clan implements IIdentifiable, INamable
 		}
 		}
 		else
 		else
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
 				PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
 			{
 			{
 				ps.setInt(1, 0);
 				ps.setInt(1, 0);
@@ -290,7 +290,7 @@ public class L2Clan implements IIdentifiable, INamable
 		}
 		}
 		else
 		else
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
 				PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
 			{
 			{
 				ps.setInt(1, EnumIntBitmask.getAllBitmask(ClanPrivilege.class));
 				ps.setInt(1, EnumIntBitmask.getAllBitmask(ClanPrivilege.class));
@@ -842,7 +842,7 @@ public class L2Clan implements IIdentifiable, INamable
 	 */
 	 */
 	public void updateBloodAllianceCountInDB()
 	public void updateBloodAllianceCountInDB()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_alliance_count=? WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_alliance_count=? WHERE clan_id=?"))
 		{
 		{
 			ps.setInt(1, getBloodAllianceCount());
 			ps.setInt(1, getBloodAllianceCount());
@@ -886,7 +886,7 @@ public class L2Clan implements IIdentifiable, INamable
 	 */
 	 */
 	public void updateBloodOathCountInDB()
 	public void updateBloodOathCountInDB()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_oath_count=? WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_oath_count=? WHERE clan_id=?"))
 		{
 		{
 			ps.setInt(1, getBloodOathCount());
 			ps.setInt(1, getBloodOathCount());
@@ -904,7 +904,7 @@ public class L2Clan implements IIdentifiable, INamable
 	 */
 	 */
 	public void updateClanScoreInDB()
 	public void updateClanScoreInDB()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET reputation_score=? WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET reputation_score=? WHERE clan_id=?"))
 		{
 		{
 			ps.setInt(1, getReputationScore());
 			ps.setInt(1, getReputationScore());
@@ -933,7 +933,7 @@ public class L2Clan implements IIdentifiable, INamable
 	 */
 	 */
 	public void updateClanInDB()
 	public void updateClanInDB()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=?,new_leader_id=? WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=?,new_leader_id=? WHERE clan_id=?"))
 		{
 		{
 			ps.setInt(1, getLeaderId());
 			ps.setInt(1, getLeaderId());
@@ -975,7 +975,7 @@ public class L2Clan implements IIdentifiable, INamable
 	 */
 	 */
 	public void store()
 	public void store()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
 			PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
@@ -1010,7 +1010,7 @@ public class L2Clan implements IIdentifiable, INamable
 	 */
 	 */
 	private void removeMemberInDatabase(L2ClanMember member, long clanJoinExpiryTime, long clanCreateExpiryTime)
 	private void removeMemberInDatabase(L2ClanMember member, long clanJoinExpiryTime, long clanCreateExpiryTime)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
 			PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
 			PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
 			PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
 			PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
 			PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
@@ -1039,7 +1039,7 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	private void restore()
 	private void restore()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
 			PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
@@ -1119,7 +1119,7 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	private void restoreNotice()
 	private void restoreNotice()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT enabled,notice FROM clan_notices WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT enabled,notice FROM clan_notices WHERE clan_id=?"))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
@@ -1150,7 +1150,7 @@ public class L2Clan implements IIdentifiable, INamable
 			notice = notice.substring(0, MAX_NOTICE_LENGTH - 1);
 			notice = notice.substring(0, MAX_NOTICE_LENGTH - 1);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO clan_notices (clan_id,notice,enabled) values (?,?,?) ON DUPLICATE KEY UPDATE notice=?,enabled=?"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO clan_notices (clan_id,notice,enabled) values (?,?,?) ON DUPLICATE KEY UPDATE notice=?,enabled=?"))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
@@ -1209,7 +1209,7 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	private void restoreSkills()
 	private void restoreSkills()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT skill_id,skill_level,sub_pledge_id FROM clan_skills WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT skill_id,skill_level,sub_pledge_id FROM clan_skills WHERE clan_id=?"))
 		{
 		{
 			// Retrieve all skills of this L2PcInstance from the database
 			// Retrieve all skills of this L2PcInstance from the database
@@ -1333,7 +1333,7 @@ public class L2Clan implements IIdentifiable, INamable
 				}
 				}
 			}
 			}
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+			try (Connection con = ConnectionFactory.getInstance().getConnection())
 			{
 			{
 				if (oldSkill != null)
 				if (oldSkill != null)
 				{
 				{
@@ -1777,7 +1777,7 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	private void restoreSubPledges()
 	private void restoreSubPledges()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT sub_pledge_id,name,leader_id FROM clan_subpledges WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT sub_pledge_id,name,leader_id FROM clan_subpledges WHERE clan_id=?"))
 		{
 		{
 			// Retrieve all subpledges of this clan from the database
 			// Retrieve all subpledges of this clan from the database
@@ -1877,7 +1877,7 @@ public class L2Clan implements IIdentifiable, INamable
 			return null;
 			return null;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO clan_subpledges (clan_id,sub_pledge_id,name,leader_id) values (?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO clan_subpledges (clan_id,sub_pledge_id,name,leader_id) values (?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
@@ -1951,7 +1951,7 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	public void updateSubPledgeInDB(int pledgeType)
 	public void updateSubPledgeInDB(int pledgeType)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_subpledges SET leader_id=?, name=? WHERE clan_id=? AND sub_pledge_id=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_subpledges SET leader_id=?, name=? WHERE clan_id=? AND sub_pledge_id=?"))
 		{
 		{
 			ps.setInt(1, getSubPledge(pledgeType).getLeaderId());
 			ps.setInt(1, getSubPledge(pledgeType).getLeaderId());
@@ -1972,20 +1972,20 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	private void restoreRankPrivs()
 	private void restoreRankPrivs()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT privs,rank,party FROM clan_privs WHERE clan_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT privs,rank,party FROM clan_privs WHERE clan_id=?"))
 		{
 		{
 			// Retrieve all skills of this L2PcInstance from the database
 			// Retrieve all skills of this L2PcInstance from the database
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
 			// _log.warning("clanPrivs restore for ClanId : "+getClanId());
 			// _log.warning("clanPrivs restore for ClanId : "+getClanId());
-			try (ResultSet rset = ps.executeQuery())
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				// Go though the recordset of this SQL query
 				// Go though the recordset of this SQL query
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					int rank = rset.getInt("rank");
+					int rank = rs.getInt("rank");
 					// int party = rset.getInt("party");
 					// int party = rset.getInt("party");
-					int privileges = rset.getInt("privs");
+					int privileges = rs.getInt("privs");
 					// Create a SubPledge object for each record
 					// Create a SubPledge object for each record
 					if (rank == -1)
 					if (rank == -1)
 					{
 					{
@@ -2025,7 +2025,7 @@ public class L2Clan implements IIdentifiable, INamable
 		{
 		{
 			_privs.get(rank).setPrivs(privs);
 			_privs.get(rank).setPrivs(privs);
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE privs = ?"))
 				PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE privs = ?"))
 			{
 			{
 				// Retrieve all skills of this L2PcInstance from the database
 				// Retrieve all skills of this L2PcInstance from the database
@@ -2062,7 +2062,7 @@ public class L2Clan implements IIdentifiable, INamable
 		{
 		{
 			_privs.put(rank, new RankPrivs(rank, 0, privs));
 			_privs.put(rank, new RankPrivs(rank, 0, privs));
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?)"))
 				PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?)"))
 			{
 			{
 				// Retrieve all skills of this L2PcInstance from the database
 				// Retrieve all skills of this L2PcInstance from the database
@@ -2186,7 +2186,7 @@ public class L2Clan implements IIdentifiable, INamable
 		
 		
 		if (storeInDb)
 		if (storeInDb)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET auction_bid_at=? WHERE clan_id=?"))
 				PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET auction_bid_at=? WHERE clan_id=?"))
 			{
 			{
 				ps.setInt(1, id);
 				ps.setInt(1, id);
@@ -2734,7 +2734,7 @@ public class L2Clan implements IIdentifiable, INamable
 	
 	
 	public void changeLevel(int level)
 	public void changeLevel(int level)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET clan_level = ? WHERE clan_id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET clan_level = ? WHERE clan_id = ?"))
 		{
 		{
 			ps.setInt(1, level);
 			ps.setInt(1, level);
@@ -2780,7 +2780,7 @@ public class L2Clan implements IIdentifiable, INamable
 		
 		
 		setCrestId(crestId);
 		setCrestId(crestId);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?"))
 		{
 		{
 			ps.setInt(1, crestId);
 			ps.setInt(1, crestId);
@@ -2817,7 +2817,7 @@ public class L2Clan implements IIdentifiable, INamable
 			allyId = getAllyId();
 			allyId = getAllyId();
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(sqlStatement))
 			PreparedStatement ps = con.prepareStatement(sqlStatement))
 		{
 		{
 			ps.setInt(1, crestId);
 			ps.setInt(1, crestId);
@@ -2863,7 +2863,7 @@ public class L2Clan implements IIdentifiable, INamable
 		
 		
 		setCrestLargeId(crestId);
 		setCrestLargeId(crestId);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_large_id = ? WHERE clan_id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_large_id = ? WHERE clan_id = ?"))
 		{
 		{
 			ps.setInt(1, crestId);
 			ps.setInt(1, crestId);

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/model/L2ClanMember.java

@@ -25,7 +25,7 @@ import java.sql.SQLException;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.instancemanager.SiegeManager;
 import com.l2jserver.gameserver.instancemanager.SiegeManager;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
@@ -270,7 +270,7 @@ public class L2ClanMember
 	 */
 	 */
 	public void updatePledgeType()
 	public void updatePledgeType()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE characters SET subpledge=? WHERE charId=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE characters SET subpledge=? WHERE charId=?"))
 		{
 		{
 			ps.setLong(1, _pledgeType);
 			ps.setLong(1, _pledgeType);
@@ -319,7 +319,7 @@ public class L2ClanMember
 	 */
 	 */
 	public void updatePowerGrade()
 	public void updatePowerGrade()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE characters SET power_grade=? WHERE charId=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE characters SET power_grade=? WHERE charId=?"))
 		{
 		{
 			ps.setLong(1, _powerGrade);
 			ps.setLong(1, _powerGrade);
@@ -748,7 +748,7 @@ public class L2ClanMember
 	 */
 	 */
 	public void saveApprenticeAndSponsor(int apprentice, int sponsor)
 	public void saveApprenticeAndSponsor(int apprentice, int sponsor)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE characters SET apprentice=?,sponsor=? WHERE charId=?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE characters SET apprentice=?,sponsor=? WHERE charId=?"))
 		{
 		{
 			ps.setInt(1, apprentice);
 			ps.setInt(1, apprentice);

+ 17 - 17
L2J_Server/java/com/l2jserver/gameserver/model/L2ContactList.java

@@ -26,7 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.SystemMessageId;
@@ -59,17 +59,17 @@ public class L2ContactList
 	{
 	{
 		_contacts.clear();
 		_contacts.clear();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(QUERY_LOAD))
 		{
 		{
-			statement.setInt(1, activeChar.getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, activeChar.getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				int contactId;
 				int contactId;
 				String contactName;
 				String contactName;
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					contactId = rset.getInt(1);
+					contactId = rs.getInt(1);
 					contactName = CharNameTable.getInstance().getNameById(contactId);
 					contactName = CharNameTable.getInstance().getNameById(contactId);
 					if ((contactName == null) || contactName.equals(activeChar.getName()) || (contactId == activeChar.getObjectId()))
 					if ((contactName == null) || contactName.equals(activeChar.getName()) || (contactId == activeChar.getObjectId()))
 					{
 					{
@@ -125,12 +125,12 @@ public class L2ContactList
 			}
 			}
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(QUERY_ADD))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(QUERY_ADD))
 		{
 		{
-			statement.setInt(1, activeChar.getObjectId());
-			statement.setInt(2, contactId);
-			statement.execute();
+			ps.setInt(1, activeChar.getObjectId());
+			ps.setInt(2, contactId);
+			ps.execute();
 			
 			
 			_contacts.add(name);
 			_contacts.add(name);
 			
 			
@@ -162,12 +162,12 @@ public class L2ContactList
 		
 		
 		_contacts.remove(name);
 		_contacts.remove(name);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(QUERY_REMOVE))
 		{
 		{
-			statement.setInt(1, activeChar.getObjectId());
-			statement.setInt(2, contactId);
-			statement.execute();
+			ps.setInt(1, activeChar.getObjectId());
+			ps.setInt(2, contactId);
+			ps.execute();
 			
 			
 			SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESFULLY_DELETED_FROM_CONTACT_LIST);
 			SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESFULLY_DELETED_FROM_CONTACT_LIST);
 			sm.addString(name);
 			sm.addString(name);

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/model/MacroList.java

@@ -31,7 +31,7 @@ import java.util.StringTokenizer;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.enums.MacroType;
 import com.l2jserver.gameserver.enums.MacroType;
 import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -131,7 +131,7 @@ public class MacroList implements IRestorable
 	
 	
 	private void registerMacroInDb(Macro macro)
 	private void registerMacroInDb(Macro macro)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, _owner.getObjectId());
 			ps.setInt(1, _owner.getObjectId());
@@ -167,7 +167,7 @@ public class MacroList implements IRestorable
 	
 	
 	private void deleteMacroFromDb(Macro macro)
 	private void deleteMacroFromDb(Macro macro)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
 		{
 		{
 			ps.setInt(1, _owner.getObjectId());
 			ps.setInt(1, _owner.getObjectId());
@@ -184,7 +184,7 @@ public class MacroList implements IRestorable
 	public boolean restoreMe()
 	public boolean restoreMe()
 	{
 	{
 		_macroses.clear();
 		_macroses.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
 		{
 		{
 			ps.setInt(1, _owner.getObjectId());
 			ps.setInt(1, _owner.getObjectId());

+ 19 - 19
L2J_Server/java/com/l2jserver/gameserver/model/ShortCuts.java

@@ -26,7 +26,7 @@ import java.util.TreeMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.interfaces.IRestorable;
 import com.l2jserver.gameserver.model.interfaces.IRestorable;
@@ -91,17 +91,17 @@ public class ShortCuts implements IRestorable
 			deleteShortCutFromDb(oldShortCut);
 			deleteShortCutFromDb(oldShortCut);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
 		{
 		{
-			statement.setInt(1, _owner.getObjectId());
-			statement.setInt(2, shortcut.getSlot());
-			statement.setInt(3, shortcut.getPage());
-			statement.setInt(4, shortcut.getType().ordinal());
-			statement.setInt(5, shortcut.getId());
-			statement.setInt(6, shortcut.getLevel());
-			statement.setInt(7, _owner.getClassIndex());
-			statement.execute();
+			ps.setInt(1, _owner.getObjectId());
+			ps.setInt(2, shortcut.getSlot());
+			ps.setInt(3, shortcut.getPage());
+			ps.setInt(4, shortcut.getType().ordinal());
+			ps.setInt(5, shortcut.getId());
+			ps.setInt(6, shortcut.getLevel());
+			ps.setInt(7, _owner.getClassIndex());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -159,14 +159,14 @@ public class ShortCuts implements IRestorable
 	 */
 	 */
 	private void deleteShortCutFromDb(Shortcut shortcut)
 	private void deleteShortCutFromDb(Shortcut shortcut)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
 		{
 		{
-			statement.setInt(1, _owner.getObjectId());
-			statement.setInt(2, shortcut.getSlot());
-			statement.setInt(3, shortcut.getPage());
-			statement.setInt(4, _owner.getClassIndex());
-			statement.execute();
+			ps.setInt(1, _owner.getObjectId());
+			ps.setInt(2, shortcut.getSlot());
+			ps.setInt(3, shortcut.getPage());
+			ps.setInt(4, _owner.getClassIndex());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -178,7 +178,7 @@ public class ShortCuts implements IRestorable
 	public boolean restoreMe()
 	public boolean restoreMe()
 	{
 	{
 		_shortCuts.clear();
 		_shortCuts.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE charId=? AND class_index=?"))
 			PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE charId=? AND class_index=?"))
 		{
 		{
 			statement.setInt(1, _owner.getObjectId());
 			statement.setInt(1, _owner.getObjectId());

+ 12 - 11
L2J_Server/java/com/l2jserver/gameserver/model/UIKeysSettings.java

@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.xml.impl.UIData;
 import com.l2jserver.gameserver.data.xml.impl.UIData;
 
 
 /**
 /**
@@ -95,6 +95,7 @@ public class UIKeysSettings
 			return;
 			return;
 		}
 		}
 		
 		
+		// TODO(Zoey76): Refactor this to use batch.
 		query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
 		query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
 		for (int category : _storedCategories.keySet())
 		for (int category : _storedCategories.keySet())
 		{
 		{
@@ -105,7 +106,7 @@ public class UIKeysSettings
 			}
 			}
 		}
 		}
 		query = query.substring(0, query.length() - 1) + "; ";
 		query = query.substring(0, query.length() - 1) + "; ";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement(query))
 			PreparedStatement statement = con.prepareStatement(query))
 		{
 		{
 			statement.execute();
 			statement.execute();
@@ -126,7 +127,7 @@ public class UIKeysSettings
 		}
 		}
 		query = query.substring(0, query.length() - 1) + ";";
 		query = query.substring(0, query.length() - 1) + ";";
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement(query))
 			PreparedStatement statement = con.prepareStatement(query))
 		{
 		{
 			statement.execute();
 			statement.execute();
@@ -147,11 +148,11 @@ public class UIKeysSettings
 		
 		
 		_storedCategories = new HashMap<>();
 		_storedCategories = new HashMap<>();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
 		{
 		{
-			stmt.setInt(1, _playerObjId);
-			try (ResultSet rs = stmt.executeQuery())
+			ps.setInt(1, _playerObjId);
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				while (rs.next())
 				while (rs.next())
 				{
 				{
@@ -179,11 +180,11 @@ public class UIKeysSettings
 		
 		
 		_storedKeys = new HashMap<>();
 		_storedKeys = new HashMap<>();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
 		{
 		{
-			stmt.setInt(1, _playerObjId);
-			try (ResultSet rs = stmt.executeQuery())
+			ps.setInt(1, _playerObjId);
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				while (rs.next())
 				while (rs.next())
 				{
 				{

+ 303 - 305
L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -49,7 +49,7 @@ import java.util.concurrent.locks.ReentrantLock;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.ItemsAutoDestroy;
 import com.l2jserver.gameserver.ItemsAutoDestroy;
@@ -1349,14 +1349,14 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	private void insertNewRecipeData(int recipeId, boolean isDwarf)
 	private void insertNewRecipeData(int recipeId, boolean isDwarf)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)"))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, recipeId);
-			statement.setInt(3, isDwarf ? _classIndex : 0);
-			statement.setInt(4, isDwarf ? 1 : 0);
-			statement.execute();
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, recipeId);
+			ps.setInt(3, isDwarf ? _classIndex : 0);
+			ps.setInt(4, isDwarf ? 1 : 0);
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -1366,13 +1366,13 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	private void deleteRecipeData(int recipeId, boolean isDwarf)
 	private void deleteRecipeData(int recipeId, boolean isDwarf)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?"))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, recipeId);
-			statement.setInt(3, isDwarf ? _classIndex : 0);
-			statement.execute();
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, recipeId);
+			ps.setInt(3, isDwarf ? _classIndex : 0);
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -6679,13 +6679,13 @@ public final class L2PcInstance extends L2Playable
 	 */
 	 */
 	public void updateOnlineStatus()
 	public void updateOnlineStatus()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?"))
 		{
 		{
-			statement.setInt(1, isOnlineInt());
-			statement.setLong(2, System.currentTimeMillis());
-			statement.setInt(3, getObjectId());
-			statement.execute();
+			ps.setInt(1, isOnlineInt());
+			ps.setLong(2, System.currentTimeMillis());
+			ps.setInt(3, getObjectId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -6699,47 +6699,47 @@ public final class L2PcInstance extends L2Playable
 	 */
 	 */
 	private boolean createDb()
 	private boolean createDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(INSERT_CHARACTER))
-		{
-			statement.setString(1, _accountName);
-			statement.setInt(2, getObjectId());
-			statement.setString(3, getName());
-			statement.setInt(4, getLevel());
-			statement.setInt(5, getMaxHp());
-			statement.setDouble(6, getCurrentHp());
-			statement.setInt(7, getMaxCp());
-			statement.setDouble(8, getCurrentCp());
-			statement.setInt(9, getMaxMp());
-			statement.setDouble(10, getCurrentMp());
-			statement.setInt(11, getAppearance().getFace());
-			statement.setInt(12, getAppearance().getHairStyle());
-			statement.setInt(13, getAppearance().getHairColor());
-			statement.setInt(14, getAppearance().getSex() ? 1 : 0);
-			statement.setLong(15, getExp());
-			statement.setInt(16, getSp());
-			statement.setInt(17, getKarma());
-			statement.setInt(18, getFame());
-			statement.setInt(19, getPvpKills());
-			statement.setInt(20, getPkKills());
-			statement.setInt(21, getClanId());
-			statement.setInt(22, getRace().ordinal());
-			statement.setInt(23, getClassId().getId());
-			statement.setLong(24, getDeleteTimer());
-			statement.setInt(25, hasDwarvenCraft() ? 1 : 0);
-			statement.setString(26, getTitle());
-			statement.setInt(27, getAppearance().getTitleColor());
-			statement.setInt(28, getAccessLevel().getLevel());
-			statement.setInt(29, isOnlineInt());
-			statement.setInt(30, isIn7sDungeon() ? 1 : 0);
-			statement.setInt(31, getClanPrivileges().getBitmask());
-			statement.setInt(32, getWantsPeace());
-			statement.setInt(33, getBaseClass());
-			statement.setInt(34, getNewbie());
-			statement.setInt(35, isNoble() ? 1 : 0);
-			statement.setLong(36, 0);
-			statement.setDate(37, new Date(getCreateDate().getTimeInMillis()));
-			statement.executeUpdate();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(INSERT_CHARACTER))
+		{
+			ps.setString(1, _accountName);
+			ps.setInt(2, getObjectId());
+			ps.setString(3, getName());
+			ps.setInt(4, getLevel());
+			ps.setInt(5, getMaxHp());
+			ps.setDouble(6, getCurrentHp());
+			ps.setInt(7, getMaxCp());
+			ps.setDouble(8, getCurrentCp());
+			ps.setInt(9, getMaxMp());
+			ps.setDouble(10, getCurrentMp());
+			ps.setInt(11, getAppearance().getFace());
+			ps.setInt(12, getAppearance().getHairStyle());
+			ps.setInt(13, getAppearance().getHairColor());
+			ps.setInt(14, getAppearance().getSex() ? 1 : 0);
+			ps.setLong(15, getExp());
+			ps.setInt(16, getSp());
+			ps.setInt(17, getKarma());
+			ps.setInt(18, getFame());
+			ps.setInt(19, getPvpKills());
+			ps.setInt(20, getPkKills());
+			ps.setInt(21, getClanId());
+			ps.setInt(22, getRace().ordinal());
+			ps.setInt(23, getClassId().getId());
+			ps.setLong(24, getDeleteTimer());
+			ps.setInt(25, hasDwarvenCraft() ? 1 : 0);
+			ps.setString(26, getTitle());
+			ps.setInt(27, getAppearance().getTitleColor());
+			ps.setInt(28, getAccessLevel().getLevel());
+			ps.setInt(29, isOnlineInt());
+			ps.setInt(30, isIn7sDungeon() ? 1 : 0);
+			ps.setInt(31, getClanPrivileges().getBitmask());
+			ps.setInt(32, getWantsPeace());
+			ps.setInt(33, getBaseClass());
+			ps.setInt(34, getNewbie());
+			ps.setInt(35, isNoble() ? 1 : 0);
+			ps.setLong(36, 0);
+			ps.setDate(37, new Date(getCreateDate().getTimeInMillis()));
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -6761,12 +6761,12 @@ public final class L2PcInstance extends L2Playable
 		double currentCp = 0;
 		double currentCp = 0;
 		double currentHp = 0;
 		double currentHp = 0;
 		double currentMp = 0;
 		double currentMp = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER))
 		{
 		{
 			// Retrieve the L2PcInstance from the characters table of the database
 			// Retrieve the L2PcInstance from the characters table of the database
-			statement.setInt(1, objectId);
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, objectId);
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				if (rset.next())
 				if (rset.next())
 				{
 				{
@@ -7073,11 +7073,11 @@ public final class L2PcInstance extends L2Playable
 	 */
 	 */
 	private static boolean restoreSubClassData(L2PcInstance player)
 	private static boolean restoreSubClassData(L2PcInstance player)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
 		{
 		{
-			statement.setInt(1, player.getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, player.getObjectId());
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				while (rset.next())
 				while (rset.next())
 				{
 				{
@@ -7154,16 +7154,16 @@ public final class L2PcInstance extends L2Playable
 	private void restoreRecipeBook(boolean loadCommon)
 	private void restoreRecipeBook(boolean loadCommon)
 	{
 	{
 		final String sql = loadCommon ? "SELECT id, type, classIndex FROM character_recipebook WHERE charId=?" : "SELECT id FROM character_recipebook WHERE charId=? AND classIndex=? AND type = 1";
 		final String sql = loadCommon ? "SELECT id, type, classIndex FROM character_recipebook WHERE charId=?" : "SELECT id FROM character_recipebook WHERE charId=? AND classIndex=? AND type = 1";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(sql))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(sql))
 		{
 		{
-			statement.setInt(1, getObjectId());
+			ps.setInt(1, getObjectId());
 			if (!loadCommon)
 			if (!loadCommon)
 			{
 			{
-				statement.setInt(2, _classIndex);
+				ps.setInt(2, _classIndex);
 			}
 			}
 			
 			
-			try (ResultSet rset = statement.executeQuery())
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				_dwarvenRecipeBook.clear();
 				_dwarvenRecipeBook.clear();
 				
 				
@@ -7207,11 +7207,11 @@ public final class L2PcInstance extends L2Playable
 	private void loadPremiumItemList()
 	private void loadPremiumItemList()
 	{
 	{
 		final String sql = "SELECT itemNum, itemId, itemCount, itemSender FROM character_premium_items WHERE charId=?";
 		final String sql = "SELECT itemNum, itemId, itemCount, itemSender FROM character_premium_items WHERE charId=?";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(sql))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(sql))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				while (rset.next())
 				while (rset.next())
 				{
 				{
@@ -7231,13 +7231,13 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	public void updatePremiumItem(int itemNum, long newcount)
 	public void updatePremiumItem(int itemNum, long newcount)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? "))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? "))
 		{
 		{
-			statement.setLong(1, newcount);
-			statement.setInt(2, getObjectId());
-			statement.setInt(3, itemNum);
-			statement.execute();
+			ps.setLong(1, newcount);
+			ps.setInt(2, getObjectId());
+			ps.setInt(3, itemNum);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -7247,12 +7247,12 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	public void deletePremiumItem(int itemNum)
 	public void deletePremiumItem(int itemNum)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? "))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? "))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, itemNum);
-			statement.execute();
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, itemNum);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -7305,43 +7305,43 @@ public final class L2PcInstance extends L2Playable
 		long exp = getStat().getBaseExp();
 		long exp = getStat().getBaseExp();
 		int level = getStat().getBaseLevel();
 		int level = getStat().getBaseLevel();
 		int sp = getStat().getBaseSp();
 		int sp = getStat().getBaseSp();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER))
-		{
-			statement.setInt(1, level);
-			statement.setInt(2, getMaxHp());
-			statement.setDouble(3, getCurrentHp());
-			statement.setInt(4, getMaxCp());
-			statement.setDouble(5, getCurrentCp());
-			statement.setInt(6, getMaxMp());
-			statement.setDouble(7, getCurrentMp());
-			statement.setInt(8, getAppearance().getFace());
-			statement.setInt(9, getAppearance().getHairStyle());
-			statement.setInt(10, getAppearance().getHairColor());
-			statement.setInt(11, getAppearance().getSex() ? 1 : 0);
-			statement.setInt(12, getHeading());
-			statement.setInt(13, _observerMode ? _lastLoc.getX() : getX());
-			statement.setInt(14, _observerMode ? _lastLoc.getY() : getY());
-			statement.setInt(15, _observerMode ? _lastLoc.getZ() : getZ());
-			statement.setLong(16, exp);
-			statement.setLong(17, getExpBeforeDeath());
-			statement.setInt(18, sp);
-			statement.setInt(19, getKarma());
-			statement.setInt(20, getFame());
-			statement.setInt(21, getPvpKills());
-			statement.setInt(22, getPkKills());
-			statement.setInt(23, getClanId());
-			statement.setInt(24, getRace().ordinal());
-			statement.setInt(25, getClassId().getId());
-			statement.setLong(26, getDeleteTimer());
-			statement.setString(27, getTitle());
-			statement.setInt(28, getAppearance().getTitleColor());
-			statement.setInt(29, getAccessLevel().getLevel());
-			statement.setInt(30, isOnlineInt());
-			statement.setInt(31, isIn7sDungeon() ? 1 : 0);
-			statement.setInt(32, getClanPrivileges().getBitmask());
-			statement.setInt(33, getWantsPeace());
-			statement.setInt(34, getBaseClass());
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))
+		{
+			ps.setInt(1, level);
+			ps.setInt(2, getMaxHp());
+			ps.setDouble(3, getCurrentHp());
+			ps.setInt(4, getMaxCp());
+			ps.setDouble(5, getCurrentCp());
+			ps.setInt(6, getMaxMp());
+			ps.setDouble(7, getCurrentMp());
+			ps.setInt(8, getAppearance().getFace());
+			ps.setInt(9, getAppearance().getHairStyle());
+			ps.setInt(10, getAppearance().getHairColor());
+			ps.setInt(11, getAppearance().getSex() ? 1 : 0);
+			ps.setInt(12, getHeading());
+			ps.setInt(13, _observerMode ? _lastLoc.getX() : getX());
+			ps.setInt(14, _observerMode ? _lastLoc.getY() : getY());
+			ps.setInt(15, _observerMode ? _lastLoc.getZ() : getZ());
+			ps.setLong(16, exp);
+			ps.setLong(17, getExpBeforeDeath());
+			ps.setInt(18, sp);
+			ps.setInt(19, getKarma());
+			ps.setInt(20, getFame());
+			ps.setInt(21, getPvpKills());
+			ps.setInt(22, getPkKills());
+			ps.setInt(23, getClanId());
+			ps.setInt(24, getRace().ordinal());
+			ps.setInt(25, getClassId().getId());
+			ps.setLong(26, getDeleteTimer());
+			ps.setString(27, getTitle());
+			ps.setInt(28, getAppearance().getTitleColor());
+			ps.setInt(29, getAccessLevel().getLevel());
+			ps.setInt(30, isOnlineInt());
+			ps.setInt(31, isIn7sDungeon() ? 1 : 0);
+			ps.setInt(32, getClanPrivileges().getBitmask());
+			ps.setInt(33, getWantsPeace());
+			ps.setInt(34, getBaseClass());
 			
 			
 			long totalOnlineTime = _onlineTime;
 			long totalOnlineTime = _onlineTime;
 			if (_onlineBeginTime > 0)
 			if (_onlineBeginTime > 0)
@@ -7349,24 +7349,24 @@ public final class L2PcInstance extends L2Playable
 				totalOnlineTime += (System.currentTimeMillis() - _onlineBeginTime) / 1000;
 				totalOnlineTime += (System.currentTimeMillis() - _onlineBeginTime) / 1000;
 			}
 			}
 			
 			
-			statement.setLong(35, totalOnlineTime);
-			statement.setInt(36, getNewbie());
-			statement.setInt(37, isNoble() ? 1 : 0);
-			statement.setInt(38, getPowerGrade());
-			statement.setInt(39, getPledgeType());
-			statement.setInt(40, getLvlJoinedAcademy());
-			statement.setLong(41, getApprentice());
-			statement.setLong(42, getSponsor());
-			statement.setLong(43, getClanJoinExpiryTime());
-			statement.setLong(44, getClanCreateExpiryTime());
-			statement.setString(45, getName());
-			statement.setLong(46, getDeathPenaltyBuffLevel());
-			statement.setInt(47, getBookMarkSlot());
-			statement.setInt(48, getVitalityPoints());
-			statement.setString(49, getLang());
-			statement.setInt(50, getObjectId());
-			
-			statement.execute();
+			ps.setLong(35, totalOnlineTime);
+			ps.setInt(36, getNewbie());
+			ps.setInt(37, isNoble() ? 1 : 0);
+			ps.setInt(38, getPowerGrade());
+			ps.setInt(39, getPledgeType());
+			ps.setInt(40, getLvlJoinedAcademy());
+			ps.setLong(41, getApprentice());
+			ps.setLong(42, getSponsor());
+			ps.setLong(43, getClanJoinExpiryTime());
+			ps.setLong(44, getClanCreateExpiryTime());
+			ps.setString(45, getName());
+			ps.setLong(46, getDeathPenaltyBuffLevel());
+			ps.setInt(47, getBookMarkSlot());
+			ps.setInt(48, getVitalityPoints());
+			ps.setString(49, getLang());
+			ps.setInt(50, getObjectId());
+			
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -7381,20 +7381,21 @@ public final class L2PcInstance extends L2Playable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
+		// TODO(Zoey76): Refactor this to use batch.
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
 		{
 		{
 			for (SubClass subClass : getSubClasses().values())
 			for (SubClass subClass : getSubClasses().values())
 			{
 			{
-				statement.setLong(1, subClass.getExp());
-				statement.setInt(2, subClass.getSp());
-				statement.setInt(3, subClass.getLevel());
-				statement.setInt(4, subClass.getClassId());
-				statement.setInt(5, getObjectId());
-				statement.setInt(6, subClass.getClassIndex());
+				ps.setLong(1, subClass.getExp());
+				ps.setInt(2, subClass.getSp());
+				ps.setInt(3, subClass.getLevel());
+				ps.setInt(4, subClass.getClassId());
+				ps.setInt(5, getObjectId());
+				ps.setInt(6, subClass.getClassIndex());
 				
 				
-				statement.execute();
-				statement.clearParameters();
+				ps.execute();
+				ps.clearParameters();
 			}
 			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
@@ -7411,7 +7412,7 @@ public final class L2PcInstance extends L2Playable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE);
 			PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE);
 			PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE);)
 			PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE);)
 		{
 		{
@@ -7514,7 +7515,7 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	private void storeItemReuseDelay()
 	private void storeItemReuseDelay()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
 			PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
 			PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE))
 			PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE))
 		{
 		{
@@ -7618,14 +7619,14 @@ public final class L2PcInstance extends L2Playable
 		final Skill oldSkill = super.removeSkill(skill, true);
 		final Skill oldSkill = super.removeSkill(skill, true);
 		if (oldSkill != null)
 		if (oldSkill != null)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
 			{
 			{
 				// Remove or update a L2PcInstance skill from the character_skills table of the database
 				// Remove or update a L2PcInstance skill from the character_skills table of the database
-				statement.setInt(1, oldSkill.getId());
-				statement.setInt(2, getObjectId());
-				statement.setInt(3, getClassIndex());
-				statement.execute();
+				ps.setInt(1, oldSkill.getId());
+				ps.setInt(2, getObjectId());
+				ps.setInt(3, getClassIndex());
+				ps.execute();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -7661,7 +7662,7 @@ public final class L2PcInstance extends L2Playable
 	private void storeSkill(Skill newSkill, Skill oldSkill, int newClassIndex)
 	private void storeSkill(Skill newSkill, Skill oldSkill, int newClassIndex)
 	{
 	{
 		final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
 		final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			if ((oldSkill != null) && (newSkill != null))
 			if ((oldSkill != null) && (newSkill != null))
 			{
 			{
@@ -7709,7 +7710,7 @@ public final class L2PcInstance extends L2Playable
 		}
 		}
 		
 		
 		final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
 		final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS))
 			PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS))
 		{
 		{
 			con.setAutoCommit(false);
 			con.setAutoCommit(false);
@@ -7736,18 +7737,18 @@ public final class L2PcInstance extends L2Playable
 	 */
 	 */
 	private void restoreSkills()
 	private void restoreSkills()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
 		{
 		{
 			// Retrieve all skills of this L2PcInstance from the database
 			// Retrieve all skills of this L2PcInstance from the database
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, getClassIndex());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, getClassIndex());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					final int id = rset.getInt("skill_id");
-					final int level = rset.getInt("skill_level");
+					final int id = rs.getInt("skill_id");
+					final int level = rs.getInt("skill_level");
 					
 					
 					// Create a L2Skill object for each record
 					// Create a L2Skill object for each record
 					final Skill skill = SkillData.getInstance().getSkill(id, level);
 					final Skill skill = SkillData.getInstance().getSkill(id, level);
@@ -7787,21 +7788,21 @@ public final class L2PcInstance extends L2Playable
 	@Override
 	@Override
 	public void restoreEffects()
 	public void restoreEffects()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, getClassIndex());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, getClassIndex());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					int remainingTime = rset.getInt("remaining_time");
-					long reuseDelay = rset.getLong("reuse_delay");
-					long systime = rset.getLong("systime");
-					int restoreType = rset.getInt("restore_type");
+					int remainingTime = rs.getInt("remaining_time");
+					long reuseDelay = rs.getLong("reuse_delay");
+					long systime = rs.getLong("systime");
+					int restoreType = rs.getInt("restore_type");
 					
 					
-					final Skill skill = SkillData.getInstance().getSkill(rset.getInt("skill_id"), rset.getInt("skill_level"));
+					final Skill skill = SkillData.getInstance().getSkill(rs.getInt("skill_id"), rs.getInt("skill_level"));
 					if (skill == null)
 					if (skill == null)
 					{
 					{
 						continue;
 						continue;
@@ -7844,12 +7845,12 @@ public final class L2PcInstance extends L2Playable
 	 */
 	 */
 	private void restoreItemReuse()
 	private void restoreItemReuse()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
 			PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);)
 			PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);)
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				int itemId;
 				int itemId;
 				@SuppressWarnings("unused")
 				@SuppressWarnings("unused")
@@ -7858,12 +7859,12 @@ public final class L2PcInstance extends L2Playable
 				long systime;
 				long systime;
 				boolean isInInventory;
 				boolean isInInventory;
 				long remainingTime;
 				long remainingTime;
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					itemId = rset.getInt("itemId");
-					itemObjId = rset.getInt("itemObjId");
-					reuseDelay = rset.getLong("reuseDelay");
-					systime = rset.getLong("systime");
+					itemId = rs.getInt("itemId");
+					itemObjId = rs.getInt("itemObjId");
+					reuseDelay = rs.getLong("reuseDelay");
+					systime = rs.getLong("systime");
 					isInInventory = true;
 					isInInventory = true;
 					
 					
 					// Using item Id
 					// Using item Id
@@ -7915,12 +7916,12 @@ public final class L2PcInstance extends L2Playable
 			_henna[i] = null;
 			_henna[i] = null;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_HENNAS))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, getClassIndex());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, getClassIndex());
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				int slot;
 				int slot;
 				int symbolId;
 				int symbolId;
@@ -8003,13 +8004,13 @@ public final class L2PcInstance extends L2Playable
 		
 		
 		_henna[slot] = null;
 		_henna[slot] = null;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(DELETE_CHAR_HENNA))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, slot + 1);
-			statement.setInt(3, getClassIndex());
-			statement.execute();
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, slot + 1);
+			ps.setInt(3, getClassIndex());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -8056,14 +8057,14 @@ public final class L2PcInstance extends L2Playable
 				// Calculate Henna modifiers of this L2PcInstance
 				// Calculate Henna modifiers of this L2PcInstance
 				recalcHennaStats();
 				recalcHennaStats();
 				
 				
-				try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-					PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA))
+				try (Connection con = ConnectionFactory.getInstance().getConnection();
+					PreparedStatement ps = con.prepareStatement(ADD_CHAR_HENNA))
 				{
 				{
-					statement.setInt(1, getObjectId());
-					statement.setInt(2, henna.getDyeId());
-					statement.setInt(3, i + 1);
-					statement.setInt(4, getClassIndex());
-					statement.execute();
+					ps.setInt(1, getObjectId());
+					ps.setInt(2, henna.getDyeId());
+					ps.setInt(3, i + 1);
+					ps.setInt(4, getClassIndex());
+					ps.execute();
 				}
 				}
 				catch (Exception e)
 				catch (Exception e)
 				{
 				{
@@ -10008,17 +10009,17 @@ public final class L2PcInstance extends L2Playable
 			newClass.setClassId(classId);
 			newClass.setClassId(classId);
 			newClass.setClassIndex(classIndex);
 			newClass.setClassIndex(classIndex);
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(ADD_CHAR_SUBCLASS))
 			{
 			{
 				// Store the basic info about this new sub-class.
 				// Store the basic info about this new sub-class.
-				statement.setInt(1, getObjectId());
-				statement.setInt(2, newClass.getClassId());
-				statement.setLong(3, newClass.getExp());
-				statement.setInt(4, newClass.getSp());
-				statement.setInt(5, newClass.getLevel());
-				statement.setInt(6, newClass.getClassIndex()); // <-- Added
-				statement.execute();
+				ps.setInt(1, getObjectId());
+				ps.setInt(2, newClass.getClassId());
+				ps.setLong(3, newClass.getExp());
+				ps.setInt(4, newClass.getSp());
+				ps.setInt(5, newClass.getLevel());
+				ps.setInt(6, newClass.getClassIndex()); // <-- Added
+				ps.execute();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -10073,7 +10074,7 @@ public final class L2PcInstance extends L2Playable
 		
 		
 		try
 		try
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS);
 				PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS);
 				PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
 				PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
 				PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE);
 				PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE);
@@ -12703,14 +12704,13 @@ public final class L2PcInstance extends L2Playable
 	{
 	{
 		if ((_controlItemId != 0) && (petId != 0))
 		if ((_controlItemId != 0) && (petId != 0))
 		{
 		{
-			String req;
-			req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(req))
+			final String req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(req))
 			{
 			{
-				statement.setInt(1, getCurrentFeed());
-				statement.setInt(2, _controlItemId);
-				statement.executeUpdate();
+				ps.setInt(1, getCurrentFeed());
+				ps.setInt(2, _controlItemId);
+				ps.executeUpdate();
 				_controlItemId = 0;
 				_controlItemId = 0;
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
@@ -12852,15 +12852,15 @@ public final class L2PcInstance extends L2Playable
 			bookmark.setTag(tag);
 			bookmark.setTag(tag);
 			bookmark.setName(name);
 			bookmark.setName(name);
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(UPDATE_TP_BOOKMARK))
 			{
 			{
-				statement.setInt(1, icon);
-				statement.setString(2, tag);
-				statement.setString(3, name);
-				statement.setInt(4, getObjectId());
-				statement.setInt(5, id);
-				statement.execute();
+				ps.setInt(1, icon);
+				ps.setString(2, tag);
+				ps.setString(3, name);
+				ps.setInt(4, getObjectId());
+				ps.setInt(5, id);
+				ps.execute();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -12875,12 +12875,12 @@ public final class L2PcInstance extends L2Playable
 	{
 	{
 		if (_tpbookmarks.remove(id) != null)
 		if (_tpbookmarks.remove(id) != null)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(DELETE_TP_BOOKMARK))
 			{
 			{
-				statement.setInt(1, getObjectId());
-				statement.setInt(2, id);
-				statement.execute();
+				ps.setInt(1, getObjectId());
+				ps.setInt(2, id);
+				ps.execute();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -13023,18 +13023,18 @@ public final class L2PcInstance extends L2Playable
 		sm.addItemName(20033);
 		sm.addItemName(20033);
 		sendPacket(sm);
 		sendPacket(sm);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(INSERT_TP_BOOKMARK))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, id);
-			statement.setInt(3, x);
-			statement.setInt(4, y);
-			statement.setInt(5, z);
-			statement.setInt(6, icon);
-			statement.setString(7, tag);
-			statement.setString(8, name);
-			statement.execute();
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, id);
+			ps.setInt(3, x);
+			ps.setInt(4, y);
+			ps.setInt(5, z);
+			ps.setInt(6, icon);
+			ps.setString(7, tag);
+			ps.setString(8, name);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -13045,15 +13045,15 @@ public final class L2PcInstance extends L2Playable
 	
 	
 	public void restoreTeleportBookmark()
 	public void restoreTeleportBookmark()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_TP_BOOKMARK))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					_tpbookmarks.put(rset.getInt("Id"), new TeleportBookmark(rset.getInt("Id"), rset.getInt("x"), rset.getInt("y"), rset.getInt("z"), rset.getInt("icon"), rset.getString("tag"), rset.getString("name")));
+					_tpbookmarks.put(rs.getInt("Id"), new TeleportBookmark(rs.getInt("Id"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("icon"), rs.getString("tag"), rs.getString("name")));
 				}
 				}
 			}
 			}
 		}
 		}
@@ -13267,15 +13267,15 @@ public final class L2PcInstance extends L2Playable
 		_friendList.clear();
 		_friendList.clear();
 		
 		
 		final String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0";
 		final String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(sqlQuery))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(sqlQuery))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					int friendId = rset.getInt("friendId");
+					int friendId = rs.getInt("friendId");
 					if (friendId == getObjectId())
 					if (friendId == getObjectId())
 					{
 					{
 						continue;
 						continue;
@@ -13357,28 +13357,26 @@ public final class L2PcInstance extends L2Playable
 	{
 	{
 		if (hasManufactureShop())
 		if (hasManufactureShop())
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+			try (Connection con = ConnectionFactory.getInstance().getConnection())
 			{
 			{
-				try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
+				try (PreparedStatement ps = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
 				{
 				{
-					st.setInt(1, getObjectId());
-					st.execute();
+					ps.setInt(1, getObjectId());
+					ps.execute();
 				}
 				}
 				
 				
-				try (PreparedStatement st = con.prepareStatement(INSERT_CHAR_RECIPE_SHOP))
+				try (PreparedStatement ps = con.prepareStatement(INSERT_CHAR_RECIPE_SHOP))
 				{
 				{
 					AtomicInteger slot = new AtomicInteger(1);
 					AtomicInteger slot = new AtomicInteger(1);
-					con.setAutoCommit(false);
 					for (L2ManufactureItem item : _manufactureItems.values())
 					for (L2ManufactureItem item : _manufactureItems.values())
 					{
 					{
-						st.setInt(1, getObjectId());
-						st.setInt(2, item.getRecipeId());
-						st.setLong(3, item.getCost());
-						st.setInt(4, slot.getAndIncrement());
-						st.addBatch();
+						ps.setInt(1, getObjectId());
+						ps.setInt(2, item.getRecipeId());
+						ps.setLong(3, item.getCost());
+						ps.setInt(4, slot.getAndIncrement());
+						ps.addBatch();
 					}
 					}
-					st.executeBatch();
-					con.commit();
+					ps.executeBatch();
 				}
 				}
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
@@ -13395,15 +13393,15 @@ public final class L2PcInstance extends L2Playable
 			_manufactureItems.clear();
 			_manufactureItems.clear();
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					getManufactureItems().put(rset.getInt("recipeId"), new L2ManufactureItem(rset.getInt("recipeId"), rset.getLong("price")));
+					getManufactureItems().put(rs.getInt("recipeId"), new L2ManufactureItem(rs.getInt("recipeId"), rs.getLong("price")));
 				}
 				}
 			}
 			}
 		}
 		}
@@ -13829,13 +13827,13 @@ public final class L2PcInstance extends L2Playable
 	 */
 	 */
 	private void restorePetInventoryItems()
 	private void restorePetInventoryItems()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				setPetInvItems(rset.next() && (rset.getInt("object_id") > 0));
+				setPetInvItems(rs.next() && (rs.getInt("object_id") > 0));
 			}
 			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
@@ -13871,17 +13869,17 @@ public final class L2PcInstance extends L2Playable
 	private long loadRecommendations()
 	private long loadRecommendations()
 	{
 	{
 		long _time_left = 0;
 		long _time_left = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1"))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, getObjectId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				if (rset.next())
+				if (rs.next())
 				{
 				{
-					setRecomHave(rset.getInt("rec_have"));
-					setRecomLeft(rset.getInt("rec_left"));
-					_time_left = rset.getLong("time_left");
+					setRecomHave(rs.getInt("rec_have"));
+					setRecomLeft(rs.getInt("rec_left"));
+					_time_left = rs.getLong("time_left");
 				}
 				}
 				else
 				else
 				{
 				{
@@ -13907,18 +13905,18 @@ public final class L2PcInstance extends L2Playable
 			recoTaskEnd = Math.max(0, _recoBonusTask.getDelay(TimeUnit.MILLISECONDS));
 			recoTaskEnd = Math.max(0, _recoBonusTask.getDelay(TimeUnit.MILLISECONDS));
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE rec_have=?, rec_left=?, time_left=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE rec_have=?, rec_left=?, time_left=?"))
 		{
 		{
-			statement.setInt(1, getObjectId());
-			statement.setInt(2, getRecomHave());
-			statement.setInt(3, getRecomLeft());
-			statement.setLong(4, recoTaskEnd);
+			ps.setInt(1, getObjectId());
+			ps.setInt(2, getRecomHave());
+			ps.setInt(3, getRecomLeft());
+			ps.setLong(4, recoTaskEnd);
 			// Update part
 			// Update part
-			statement.setInt(5, getRecomHave());
-			statement.setInt(6, getRecomLeft());
-			statement.setLong(7, recoTaskEnd);
-			statement.execute();
+			ps.setInt(5, getRecomHave());
+			ps.setInt(6, getRecomLeft());
+			ps.setLong(7, recoTaskEnd);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 25 - 25
L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PetInstance.java

@@ -28,7 +28,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
 import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
@@ -796,11 +796,11 @@ public class L2PetInstance extends L2Summon
 		}
 		}
 		
 		
 		// pet control item no longer exists, delete the pet from the db
 		// pet control item no longer exists, delete the pet from the db
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
 		{
 		{
-			statement.setInt(1, getControlObjectId());
-			statement.execute();
+			ps.setInt(1, getControlObjectId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -852,12 +852,12 @@ public class L2PetInstance extends L2Summon
 	
 	
 	private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
 	private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
 		{
 		{
 			L2PetInstance pet;
 			L2PetInstance pet;
-			statement.setInt(1, control.getObjectId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, control.getObjectId());
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				if (!rset.next())
 				if (!rset.next())
 				{
 				{
@@ -953,20 +953,20 @@ public class L2PetInstance extends L2Summon
 			req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? " + "WHERE item_obj_id = ?";
 			req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? " + "WHERE item_obj_id = ?";
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(req))
-		{
-			statement.setString(1, getName());
-			statement.setInt(2, getStat().getLevel());
-			statement.setDouble(3, getStatus().getCurrentHp());
-			statement.setDouble(4, getStatus().getCurrentMp());
-			statement.setLong(5, getStat().getExp());
-			statement.setInt(6, getStat().getSp());
-			statement.setInt(7, getCurrentFed());
-			statement.setInt(8, getOwner().getObjectId());
-			statement.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
-			statement.setInt(10, getControlObjectId());
-			statement.executeUpdate();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(req))
+		{
+			ps.setString(1, getName());
+			ps.setInt(2, getStat().getLevel());
+			ps.setDouble(3, getStatus().getCurrentHp());
+			ps.setDouble(4, getStatus().getCurrentMp());
+			ps.setLong(5, getStat().getExp());
+			ps.setInt(6, getStat().getSp());
+			ps.setInt(7, getCurrentFed());
+			ps.setInt(8, getOwner().getObjectId());
+			ps.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
+			ps.setInt(10, getControlObjectId());
+			ps.executeUpdate();
 			
 			
 			_respawned = true;
 			_respawned = true;
 			
 			
@@ -1003,7 +1003,7 @@ public class L2PetInstance extends L2Summon
 		// Clear list for overwrite
 		// Clear list for overwrite
 		SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
 		SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
 			PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
 			PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
 			PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
 		{
 		{
@@ -1070,7 +1070,7 @@ public class L2PetInstance extends L2Summon
 	@Override
 	@Override
 	public void restoreEffects()
 	public void restoreEffects()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
 			PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
 			PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
 			PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
 		{
 		{

+ 18 - 18
L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2ServitorInstance.java

@@ -28,7 +28,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
 import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
 import com.l2jserver.gameserver.data.sql.impl.SummonEffectsTable;
 import com.l2jserver.gameserver.data.sql.impl.SummonEffectsTable;
@@ -260,14 +260,14 @@ public class L2ServitorInstance extends L2Summon implements Runnable
 		// Clear list for overwrite
 		// Clear list for overwrite
 		SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
 		SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE))
 		{
 		{
 			// Delete all current stored effects for summon to avoid dupe
 			// Delete all current stored effects for summon to avoid dupe
-			statement.setInt(1, getOwner().getObjectId());
-			statement.setInt(2, getOwner().getClassIndex());
-			statement.setInt(3, getReferenceSkill());
-			statement.execute();
+			ps.setInt(1, getOwner().getObjectId());
+			ps.setInt(2, getOwner().getClassIndex());
+			ps.setInt(3, getReferenceSkill());
+			ps.execute();
 			
 			
 			int buff_index = 0;
 			int buff_index = 0;
 			
 			
@@ -338,16 +338,16 @@ public class L2ServitorInstance extends L2Summon implements Runnable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
 			if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
 			{
 			{
-				try (PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
+				try (PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
 				{
 				{
-					statement.setInt(1, getOwner().getObjectId());
-					statement.setInt(2, getOwner().getClassIndex());
-					statement.setInt(3, getReferenceSkill());
-					try (ResultSet rset = statement.executeQuery())
+					ps.setInt(1, getOwner().getObjectId());
+					ps.setInt(2, getOwner().getClassIndex());
+					ps.setInt(3, getReferenceSkill());
+					try (ResultSet rset = ps.executeQuery())
 					{
 					{
 						while (rset.next())
 						while (rset.next())
 						{
 						{
@@ -368,12 +368,12 @@ public class L2ServitorInstance extends L2Summon implements Runnable
 				}
 				}
 			}
 			}
 			
 			
-			try (PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
+			try (PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE))
 			{
 			{
-				statement.setInt(1, getOwner().getObjectId());
-				statement.setInt(2, getOwner().getClassIndex());
-				statement.setInt(3, getReferenceSkill());
-				statement.executeUpdate();
+				ps.setInt(1, getOwner().getObjectId());
+				ps.setInt(2, getOwner().getClassIndex());
+				ps.setInt(3, getReferenceSkill());
+				ps.executeUpdate();
 			}
 			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)

+ 19 - 19
L2J_Server/java/com/l2jserver/gameserver/model/announce/Announcement.java

@@ -26,7 +26,7 @@ import java.sql.Statement;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 
 
 /**
 /**
  * @author UnAfraid
  * @author UnAfraid
@@ -110,14 +110,14 @@ public class Announcement implements IAnnouncement
 	@Override
 	@Override
 	public boolean storeMe()
 	public boolean storeMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
 		{
 		{
-			st.setInt(1, _type.ordinal());
-			st.setString(2, _content);
-			st.setString(3, _author);
-			st.execute();
-			try (ResultSet rset = st.getGeneratedKeys())
+			ps.setInt(1, _type.ordinal());
+			ps.setString(2, _content);
+			ps.setString(3, _author);
+			ps.execute();
+			try (ResultSet rset = ps.getGeneratedKeys())
 			{
 			{
 				if (rset.next())
 				if (rset.next())
 				{
 				{
@@ -136,14 +136,14 @@ public class Announcement implements IAnnouncement
 	@Override
 	@Override
 	public boolean updateMe()
 	public boolean updateMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
 		{
 		{
-			st.setInt(1, _type.ordinal());
-			st.setString(2, _content);
-			st.setString(3, _author);
-			st.setInt(4, _id);
-			st.execute();
+			ps.setInt(1, _type.ordinal());
+			ps.setString(2, _content);
+			ps.setString(3, _author);
+			ps.setInt(4, _id);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -156,11 +156,11 @@ public class Announcement implements IAnnouncement
 	@Override
 	@Override
 	public boolean deleteMe()
 	public boolean deleteMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement st = con.prepareStatement(DELETE_QUERY))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
 		{
 		{
-			st.setInt(1, _id);
-			st.execute();
+			ps.setInt(1, _id);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 21 - 21
L2J_Server/java/com/l2jserver/gameserver/model/announce/AutoAnnouncement.java

@@ -27,7 +27,7 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.util.Broadcast;
 import com.l2jserver.gameserver.util.Broadcast;
 
 
@@ -96,17 +96,17 @@ public final class AutoAnnouncement extends Announcement implements Runnable
 	@Override
 	@Override
 	public boolean storeMe()
 	public boolean storeMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
 		{
 		{
-			st.setInt(1, getType().ordinal());
-			st.setString(2, getContent());
-			st.setString(3, getAuthor());
-			st.setLong(4, getInitial());
-			st.setLong(5, getDelay());
-			st.setInt(6, getRepeat());
-			st.execute();
-			try (ResultSet rset = st.getGeneratedKeys())
+			ps.setInt(1, getType().ordinal());
+			ps.setString(2, getContent());
+			ps.setString(3, getAuthor());
+			ps.setLong(4, getInitial());
+			ps.setLong(5, getDelay());
+			ps.setInt(6, getRepeat());
+			ps.execute();
+			try (ResultSet rset = ps.getGeneratedKeys())
 			{
 			{
 				if (rset.next())
 				if (rset.next())
 				{
 				{
@@ -125,17 +125,17 @@ public final class AutoAnnouncement extends Announcement implements Runnable
 	@Override
 	@Override
 	public boolean updateMe()
 	public boolean updateMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
 		{
 		{
-			st.setInt(1, getType().ordinal());
-			st.setString(2, getContent());
-			st.setString(3, getAuthor());
-			st.setLong(4, getInitial());
-			st.setLong(5, getDelay());
-			st.setLong(6, getRepeat());
-			st.setLong(7, getId());
-			st.execute();
+			ps.setInt(1, getType().ordinal());
+			ps.setString(2, getContent());
+			ps.setString(3, getAuthor());
+			ps.setLong(4, getInitial());
+			ps.setLong(5, getDelay());
+			ps.setLong(6, getRepeat());
+			ps.setLong(7, getId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 12 - 12
L2J_Server/java/com/l2jserver/gameserver/model/buylist/Product.java

@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.items.L2Item;
 import com.l2jserver.gameserver.model.items.L2Item;
 
 
@@ -161,25 +161,25 @@ public final class Product
 	
 	
 	private void save()
 	private void save()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?"))
 		{
 		{
-			statement.setInt(1, getBuyListId());
-			statement.setInt(2, getItemId());
-			statement.setLong(3, getCount());
-			statement.setLong(5, getCount());
+			ps.setInt(1, getBuyListId());
+			ps.setInt(2, getItemId());
+			ps.setLong(3, getCount());
+			ps.setLong(5, getCount());
 			if ((_restockTask != null) && (_restockTask.getDelay(TimeUnit.MILLISECONDS) > 0))
 			if ((_restockTask != null) && (_restockTask.getDelay(TimeUnit.MILLISECONDS) > 0))
 			{
 			{
 				long nextRestockTime = System.currentTimeMillis() + _restockTask.getDelay(TimeUnit.MILLISECONDS);
 				long nextRestockTime = System.currentTimeMillis() + _restockTask.getDelay(TimeUnit.MILLISECONDS);
-				statement.setLong(4, nextRestockTime);
-				statement.setLong(6, nextRestockTime);
+				ps.setLong(4, nextRestockTime);
+				ps.setLong(6, nextRestockTime);
 			}
 			}
 			else
 			else
 			{
 			{
-				statement.setLong(4, 0);
-				statement.setLong(6, 0);
+				ps.setLong(4, 0);
+				ps.setLong(6, 0);
 			}
 			}
-			statement.executeUpdate();
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 62 - 62
L2J_Server/java/com/l2jserver/gameserver/model/entity/Auction.java

@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.enums.AuctionItemType;
 import com.l2jserver.gameserver.enums.AuctionItemType;
@@ -164,11 +164,11 @@ public class Auction
 	/** Load auctions */
 	/** Load auctions */
 	private void load()
 	private void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("Select * from auction where id = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?"))
 		{
 		{
-			statement.setInt(1, getId());
-			try (ResultSet rs = statement.executeQuery())
+			ps.setInt(1, getId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				while (rs.next())
 				while (rs.next())
 				{
 				{
@@ -199,11 +199,11 @@ public class Auction
 		_highestBidderName = "";
 		_highestBidderName = "";
 		_highestBidderMaxBid = 0;
 		_highestBidderMaxBid = 0;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
 		{
 		{
-			statement.setInt(1, getId());
-			try (ResultSet rs = statement.executeQuery())
+			ps.setInt(1, getId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				while (rs.next())
 				while (rs.next())
 				{
 				{
@@ -248,12 +248,12 @@ public class Auction
 	/** Save Auction Data End */
 	/** Save Auction Data End */
 	private void saveAuctionDate()
 	private void saveAuctionDate()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("Update auction set endDate = ? where id = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("Update auction set endDate = ? where id = ?"))
 		{
 		{
-			statement.setLong(1, _endDate);
-			statement.setInt(2, _id);
-			statement.execute();
+			ps.setLong(1, _endDate);
+			ps.setInt(2, _id);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -346,33 +346,33 @@ public class Auction
 	 */
 	 */
 	private void updateInDB(L2PcInstance bidder, long bid)
 	private void updateInDB(L2PcInstance bidder, long bid)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			if (_bidders.get(bidder.getClanId()) != null)
 			if (_bidders.get(bidder.getClanId()) != null)
 			{
 			{
-				try (PreparedStatement statement = con.prepareStatement("UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?"))
+				try (PreparedStatement ps = con.prepareStatement("UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?"))
 				{
 				{
-					statement.setInt(1, bidder.getClanId());
-					statement.setString(2, bidder.getClan().getLeaderName());
-					statement.setLong(3, bid);
-					statement.setLong(4, System.currentTimeMillis());
-					statement.setInt(5, getId());
-					statement.setInt(6, bidder.getClanId());
-					statement.execute();
+					ps.setInt(1, bidder.getClanId());
+					ps.setString(2, bidder.getClan().getLeaderName());
+					ps.setLong(3, bid);
+					ps.setLong(4, System.currentTimeMillis());
+					ps.setInt(5, getId());
+					ps.setInt(6, bidder.getClanId());
+					ps.execute();
 				}
 				}
 			}
 			}
 			else
 			else
 			{
 			{
-				try (PreparedStatement statement = con.prepareStatement("INSERT INTO auction_bid (id, auctionId, bidderId, bidderName, maxBid, clan_name, time_bid) VALUES (?, ?, ?, ?, ?, ?, ?)"))
+				try (PreparedStatement ps = con.prepareStatement("INSERT INTO auction_bid (id, auctionId, bidderId, bidderName, maxBid, clan_name, time_bid) VALUES (?, ?, ?, ?, ?, ?, ?)"))
 				{
 				{
-					statement.setInt(1, IdFactory.getInstance().getNextId());
-					statement.setInt(2, getId());
-					statement.setInt(3, bidder.getClanId());
-					statement.setString(4, bidder.getName());
-					statement.setLong(5, bid);
-					statement.setString(6, bidder.getClan().getName());
-					statement.setLong(7, System.currentTimeMillis());
-					statement.execute();
+					ps.setInt(1, IdFactory.getInstance().getNextId());
+					ps.setInt(2, getId());
+					ps.setInt(3, bidder.getClanId());
+					ps.setString(4, bidder.getName());
+					ps.setLong(5, bid);
+					ps.setString(6, bidder.getClan().getName());
+					ps.setLong(7, System.currentTimeMillis());
+					ps.execute();
 				}
 				}
 				if (L2World.getInstance().getPlayer(_highestBidderName) != null)
 				if (L2World.getInstance().getPlayer(_highestBidderName) != null)
 				{
 				{
@@ -403,11 +403,11 @@ public class Auction
 	/** Remove bids */
 	/** Remove bids */
 	private void removeBids()
 	private void removeBids()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
 		{
 		{
-			statement.setInt(1, getId());
-			statement.execute();
+			ps.setInt(1, getId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -436,11 +436,11 @@ public class Auction
 	public void deleteAuctionFromDB()
 	public void deleteAuctionFromDB()
 	{
 	{
 		AuctionManager.getInstance().getAuctions().remove(this);
 		AuctionManager.getInstance().getAuctions().remove(this);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
 		{
 		{
-			statement.setInt(1, _itemId);
-			statement.execute();
+			ps.setInt(1, _itemId);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -492,12 +492,12 @@ public class Auction
 	 */
 	 */
 	public synchronized void cancelBid(int bidder)
 	public synchronized void cancelBid(int bidder)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
 		{
 		{
-			statement.setInt(1, getId());
-			statement.setInt(2, bidder);
-			statement.execute();
+			ps.setInt(1, getId());
+			ps.setInt(2, bidder);
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -521,23 +521,23 @@ public class Auction
 	public void confirmAuction()
 	public void confirmAuction()
 	{
 	{
 		AuctionManager.getInstance().getAuctions().add(this);
 		AuctionManager.getInstance().getAuctions().add(this);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"))
-		{
-			statement.setInt(1, getId());
-			statement.setInt(2, _sellerId);
-			statement.setString(3, _sellerName);
-			statement.setString(4, _sellerClanName);
-			statement.setString(5, _itemType);
-			statement.setInt(6, _itemId);
-			statement.setInt(7, _itemObjectId);
-			statement.setString(8, _itemName);
-			statement.setLong(9, _itemQuantity);
-			statement.setLong(10, _startingBid);
-			statement.setLong(11, _currentBid);
-			statement.setLong(12, _endDate);
-			statement.execute();
-			statement.close();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"))
+		{
+			ps.setInt(1, getId());
+			ps.setInt(2, _sellerId);
+			ps.setString(3, _sellerName);
+			ps.setString(4, _sellerClanName);
+			ps.setString(5, _itemType);
+			ps.setInt(6, _itemId);
+			ps.setInt(7, _itemObjectId);
+			ps.setString(8, _itemName);
+			ps.setLong(9, _itemQuantity);
+			ps.setLong(10, _startingBid);
+			ps.setLong(11, _currentBid);
+			ps.setLong(12, _endDate);
+			ps.execute();
+			ps.close();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 15 - 15
L2J_Server/java/com/l2jserver/gameserver/model/entity/Castle.java

@@ -30,7 +30,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.xml.impl.DoorData;
 import com.l2jserver.gameserver.data.xml.impl.DoorData;
@@ -214,7 +214,7 @@ public final class Castle extends AbstractResidence
 		
 		
 		public void dbSave()
 		public void dbSave()
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
 			{
 			{
 				ps.setInt(1, getResidenceId());
 				ps.setInt(1, getResidenceId());
@@ -347,7 +347,7 @@ public final class Castle extends AbstractResidence
 			}
 			}
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
 		{
 		{
 			ps.setLong(1, getTreasury());
 			ps.setLong(1, getTreasury());
@@ -580,7 +580,7 @@ public final class Castle extends AbstractResidence
 		_taxPercent = taxPercent;
 		_taxPercent = taxPercent;
 		_taxRate = _taxPercent / 100.0;
 		_taxRate = _taxPercent / 100.0;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET taxPercent = ? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET taxPercent = ? WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, taxPercent);
 			ps.setInt(1, taxPercent);
@@ -627,7 +627,7 @@ public final class Castle extends AbstractResidence
 	@Override
 	@Override
 	protected void load()
 	protected void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
 			PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
 			PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
 			PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
 		{
 		{
@@ -673,7 +673,7 @@ public final class Castle extends AbstractResidence
 	/** Load All Functions */
 	/** Load All Functions */
 	private void loadFunctions()
 	private void loadFunctions()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -698,7 +698,7 @@ public final class Castle extends AbstractResidence
 	public void removeFunction(int functionType)
 	public void removeFunction(int functionType)
 	{
 	{
 		_function.remove(functionType);
 		_function.remove(functionType);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -773,7 +773,7 @@ public final class Castle extends AbstractResidence
 	// This method loads castle door upgrade data from database
 	// This method loads castle door upgrade data from database
 	private void loadDoorUpgrade()
 	private void loadDoorUpgrade()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -799,7 +799,7 @@ public final class Castle extends AbstractResidence
 			door.setCurrentHp(door.getCurrentHp());
 			door.setCurrentHp(door.getCurrentHp());
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -824,7 +824,7 @@ public final class Castle extends AbstractResidence
 		
 		
 		if (save)
 		if (save)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)"))
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)"))
 			{
 			{
 				ps.setInt(1, doorId);
 				ps.setInt(1, doorId);
@@ -851,7 +851,7 @@ public final class Castle extends AbstractResidence
 			CastleManorManager.getInstance().resetManorData(getResidenceId());
 			CastleManorManager.getInstance().resetManorData(getResidenceId());
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			// Need to remove has castle flag from clan_data, should be checked from castle table.
 			// Need to remove has castle flag from clan_data, should be checked from castle table.
 			try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?"))
 			try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?"))
@@ -1006,7 +1006,7 @@ public final class Castle extends AbstractResidence
 	
 	
 	public void updateShowNpcCrest()
 	public void updateShowNpcCrest()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
 		{
 		{
 			ps.setString(1, String.valueOf(getShowNpcCrest()));
 			ps.setString(1, String.valueOf(getShowNpcCrest()));
@@ -1101,7 +1101,7 @@ public final class Castle extends AbstractResidence
 	{
 	{
 		_ticketBuyCount = count;
 		_ticketBuyCount = count;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, _ticketBuyCount);
 			ps.setInt(1, _ticketBuyCount);
@@ -1124,7 +1124,7 @@ public final class Castle extends AbstractResidence
 	{
 	{
 		if (save)
 		if (save)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)"))
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)"))
 			{
 			{
 				ps.setInt(1, getResidenceId());
 				ps.setInt(1, getResidenceId());
@@ -1151,7 +1151,7 @@ public final class Castle extends AbstractResidence
 			ts.setUpgradeLevel(0);
 			ts.setUpgradeLevel(0);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/model/entity/ClanHall.java

@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
@@ -187,7 +187,7 @@ public abstract class ClanHall
 		
 		
 		public void dbSave()
 		public void dbSave()
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO clanhall_functions (hall_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO clanhall_functions (hall_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
 			{
 			{
 				ps.setInt(1, getId());
 				ps.setInt(1, getId());
@@ -445,7 +445,7 @@ public abstract class ClanHall
 	/** Load All Functions */
 	/** Load All Functions */
 	protected void loadFunctions()
 	protected void loadFunctions()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM clanhall_functions WHERE hall_id = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM clanhall_functions WHERE hall_id = ?"))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());
@@ -470,7 +470,7 @@ public abstract class ClanHall
 	public void removeFunction(int functionType)
 	public void removeFunction(int functionType)
 	{
 	{
 		_functions.remove(functionType);
 		_functions.remove(functionType);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_functions WHERE hall_id=? AND type=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_functions WHERE hall_id=? AND type=?"))
 		{
 		{
 			ps.setInt(1, getId());
 			ps.setInt(1, getId());

+ 5 - 5
L2J_Server/java/com/l2jserver/gameserver/model/entity/Couple.java

@@ -25,7 +25,7 @@ import java.util.Calendar;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
@@ -47,7 +47,7 @@ public class Couple
 	{
 	{
 		_Id = coupleId;
 		_Id = coupleId;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, _Id);
 			ps.setInt(1, _Id);
@@ -87,7 +87,7 @@ public class Couple
 		_weddingDate = Calendar.getInstance();
 		_weddingDate = Calendar.getInstance();
 		_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
 		_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
 		{
 		{
 			_Id = IdFactory.getInstance().getNextId();
 			_Id = IdFactory.getInstance().getNextId();
@@ -107,7 +107,7 @@ public class Couple
 	
 	
 	public void marry()
 	public void marry()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?"))
 		{
 		{
 			ps.setBoolean(1, true);
 			ps.setBoolean(1, true);
@@ -125,7 +125,7 @@ public class Couple
 	
 	
 	public void divorce()
 	public void divorce()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?"))
 		{
 		{
 			ps.setInt(1, _Id);
 			ps.setInt(1, _Id);

+ 15 - 15
L2J_Server/java/com/l2jserver/gameserver/model/entity/Fort.java

@@ -36,7 +36,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.FortUpdater;
 import com.l2jserver.gameserver.FortUpdater;
 import com.l2jserver.gameserver.FortUpdater.UpdaterType;
 import com.l2jserver.gameserver.FortUpdater.UpdaterType;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
@@ -221,7 +221,7 @@ public final class Fort extends AbstractResidence
 		
 		
 		public void dbSave()
 		public void dbSave()
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
 				PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
 			{
 			{
 				ps.setInt(1, getResidenceId());
 				ps.setInt(1, getResidenceId());
@@ -494,7 +494,7 @@ public final class Fort extends AbstractResidence
 	
 	
 	public void saveFortVariables()
 	public void saveFortVariables()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, _supplyLvL);
 			ps.setInt(1, _supplyLvL);
@@ -561,7 +561,7 @@ public final class Fort extends AbstractResidence
 	@Override
 	@Override
 	protected void load()
 	protected void load()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -623,7 +623,7 @@ public final class Fort extends AbstractResidence
 	/** Load All Functions */
 	/** Load All Functions */
 	private void loadFunctions()
 	private void loadFunctions()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -648,7 +648,7 @@ public final class Fort extends AbstractResidence
 	public void removeFunction(int functionType)
 	public void removeFunction(int functionType)
 	{
 	{
 		_function.remove(functionType);
 		_function.remove(functionType);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -750,7 +750,7 @@ public final class Fort extends AbstractResidence
 	// This method loads fort door upgrade data from database
 	// This method loads fort door upgrade data from database
 	private void loadDoorUpgrade()
 	private void loadDoorUpgrade()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -770,7 +770,7 @@ public final class Fort extends AbstractResidence
 	
 	
 	private void removeDoorUpgrade()
 	private void removeDoorUpgrade()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -784,7 +784,7 @@ public final class Fort extends AbstractResidence
 	
 	
 	private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef)
 	private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, doorId);
 			ps.setInt(1, doorId);
@@ -813,7 +813,7 @@ public final class Fort extends AbstractResidence
 			_lastOwnedTime.setTimeInMillis(0);
 			_lastOwnedTime.setTimeInMillis(0);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, clanId);
 			ps.setInt(1, clanId);
@@ -1025,7 +1025,7 @@ public final class Fort extends AbstractResidence
 	{
 	{
 		_state = state;
 		_state = state;
 		_castleId = castleId;
 		_castleId = castleId;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
 		{
 		{
 			ps.setInt(1, getFortState());
 			ps.setInt(1, getFortState());
@@ -1157,7 +1157,7 @@ public final class Fort extends AbstractResidence
 	
 	
 	private void initNpcs()
 	private void initNpcs()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -1188,7 +1188,7 @@ public final class Fort extends AbstractResidence
 	private void initSiegeNpcs()
 	private void initSiegeNpcs()
 	{
 	{
 		_siegeNpcs.clear();
 		_siegeNpcs.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
 			PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -1217,7 +1217,7 @@ public final class Fort extends AbstractResidence
 	private void initNpcCommanders()
 	private void initNpcCommanders()
 	{
 	{
 		_npcCommanders.clear();
 		_npcCommanders.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
 			PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());
@@ -1249,7 +1249,7 @@ public final class Fort extends AbstractResidence
 		_specialEnvoys.clear();
 		_specialEnvoys.clear();
 		_envoyCastles.clear();
 		_envoyCastles.clear();
 		_availableCastles.clear();
 		_availableCastles.clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading, castleId FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
 			PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading, castleId FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
 		{
 		{
 			ps.setInt(1, getResidenceId());
 			ps.setInt(1, getResidenceId());

+ 14 - 14
L2J_Server/java/com/l2jserver/gameserver/model/entity/FortSiege.java

@@ -30,7 +30,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.enums.FortTeleportWhoType;
 import com.l2jserver.gameserver.enums.FortTeleportWhoType;
@@ -496,7 +496,7 @@ public class FortSiege implements Siegable
 	/** Clear all registered siege clans from database for fort */
 	/** Clear all registered siege clans from database for fort */
 	public void clearSiegeClan()
 	public void clearSiegeClan()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?"))
 		{
 		{
 			ps.setInt(1, getFort().getResidenceId());
 			ps.setInt(1, getFort().getResidenceId());
@@ -773,15 +773,15 @@ public class FortSiege implements Siegable
 	private void removeSiegeClan(int clanId)
 	private void removeSiegeClan(int clanId)
 	{
 	{
 		final String query = (clanId != 0) ? DELETE_FORT_SIEGECLANS_BY_CLAN_ID : DELETE_FORT_SIEGECLANS;
 		final String query = (clanId != 0) ? DELETE_FORT_SIEGECLANS_BY_CLAN_ID : DELETE_FORT_SIEGECLANS;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(query))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(query))
 		{
 		{
-			statement.setInt(1, getFort().getResidenceId());
+			ps.setInt(1, getFort().getResidenceId());
 			if (clanId != 0)
 			if (clanId != 0)
 			{
 			{
-				statement.setInt(2, clanId);
+				ps.setInt(2, clanId);
 			}
 			}
-			statement.execute();
+			ps.execute();
 			
 			
 			loadSiegeClan();
 			loadSiegeClan();
 			if (getAttackerClans().isEmpty())
 			if (getAttackerClans().isEmpty())
@@ -981,7 +981,7 @@ public class FortSiege implements Siegable
 	private void loadSiegeClan()
 	private void loadSiegeClan()
 	{
 	{
 		getAttackerClans().clear();
 		getAttackerClans().clear();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?"))
 			PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?"))
 		{
 		{
 			ps.setInt(1, getFort().getResidenceId());
 			ps.setInt(1, getFort().getResidenceId());
@@ -1042,7 +1042,7 @@ public class FortSiege implements Siegable
 	/** Save siege date to database. */
 	/** Save siege date to database. */
 	private void saveSiegeDate()
 	private void saveSiegeDate()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?"))
 		{
 		{
 			ps.setLong(1, getSiegeDate().getTimeInMillis());
 			ps.setLong(1, getSiegeDate().getTimeInMillis());
@@ -1066,12 +1066,12 @@ public class FortSiege implements Siegable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
 		{
 		{
-			statement.setInt(1, clan.getId());
-			statement.setInt(2, getFort().getResidenceId());
-			statement.execute();
+			ps.setInt(1, clan.getId());
+			ps.setInt(2, getFort().getResidenceId());
+			ps.execute();
 			
 			
 			addAttacker(clan.getId());
 			addAttacker(clan.getId());
 		}
 		}

+ 34 - 34
L2J_Server/java/com/l2jserver/gameserver/model/entity/Hero.java

@@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
@@ -111,7 +111,7 @@ public class Hero
 		HERO_DIARY.clear();
 		HERO_DIARY.clear();
 		HERO_MESSAGE.clear();
 		HERO_MESSAGE.clear();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			Statement s1 = con.createStatement();
 			Statement s1 = con.createStatement();
 			ResultSet rset = s1.executeQuery(GET_HEROES);
 			ResultSet rset = s1.executeQuery(GET_HEROES);
 			PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
 			PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
@@ -209,11 +209,11 @@ public class Hero
 	 */
 	 */
 	public void loadMessage(int charId)
 	public void loadMessage(int charId)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
 		{
 		{
-			statement.setInt(1, charId);
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, charId);
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				if (rset.next())
 				if (rset.next())
 				{
 				{
@@ -231,11 +231,11 @@ public class Hero
 	{
 	{
 		final List<StatsSet> diary = new ArrayList<>();
 		final List<StatsSet> diary = new ArrayList<>();
 		int diaryentries = 0;
 		int diaryentries = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT * FROM  heroes_diary WHERE charId=? ORDER BY time ASC"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT * FROM  heroes_diary WHERE charId=? ORDER BY time ASC"))
 		{
 		{
-			statement.setInt(1, charId);
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, charId);
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				while (rset.next())
 				while (rset.next())
 				{
 				{
@@ -298,13 +298,13 @@ public class Hero
 		int _losses = 0;
 		int _losses = 0;
 		int _draws = 0;
 		int _draws = 0;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
 		{
 		{
-			statement.setInt(1, charId);
-			statement.setInt(2, charId);
-			statement.setLong(3, from);
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, charId);
+			ps.setInt(2, charId);
+			ps.setLong(3, from);
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				int charOneId;
 				int charOneId;
 				int charOneClass;
 				int charOneClass;
@@ -695,13 +695,13 @@ public class Hero
 	
 	
 	public void updateHeroes(boolean setDefault)
 	public void updateHeroes(boolean setDefault)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			if (setDefault)
 			if (setDefault)
 			{
 			{
-				try (PreparedStatement update_all = con.prepareStatement(UPDATE_ALL))
+				try (Statement s = con.createStatement())
 				{
 				{
-					update_all.execute();
+					s.executeUpdate(UPDATE_ALL);
 				}
 				}
 			}
 			}
 			else
 			else
@@ -826,14 +826,14 @@ public class Hero
 	
 	
 	public void setDiaryData(int charId, int action, int param)
 	public void setDiaryData(int charId, int action, int param)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
 		{
 		{
-			statement.setInt(1, charId);
-			statement.setLong(2, System.currentTimeMillis());
-			statement.setInt(3, action);
-			statement.setInt(4, param);
-			statement.execute();
+			ps.setInt(1, charId);
+			ps.setLong(2, System.currentTimeMillis());
+			ps.setInt(3, action);
+			ps.setInt(4, param);
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -862,12 +862,12 @@ public class Hero
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
 		{
 		{
-			statement.setString(1, HERO_MESSAGE.get(charId));
-			statement.setInt(2, charId);
-			statement.execute();
+			ps.setString(1, HERO_MESSAGE.get(charId));
+			ps.setInt(2, charId);
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -877,10 +877,10 @@ public class Hero
 	
 	
 	private void deleteItemsInDb()
 	private void deleteItemsInDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(DELETE_ITEMS))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement())
 		{
 		{
-			statement.execute();
+			s.executeUpdate(DELETE_ITEMS);
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{

+ 36 - 36
L2J_Server/java/com/l2jserver/gameserver/model/entity/Siege.java

@@ -32,7 +32,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.xml.impl.SiegeScheduleData;
 import com.l2jserver.gameserver.data.xml.impl.SiegeScheduleData;
@@ -727,11 +727,11 @@ public class Siege implements Siegable
 	/** Clear all registered siege clans from database for castle */
 	/** Clear all registered siege clans from database for castle */
 	public void clearSiegeClan()
 	public void clearSiegeClan()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
 		{
 		{
-			statement.setInt(1, getCastle().getResidenceId());
-			statement.execute();
+			ps.setInt(1, getCastle().getResidenceId());
+			ps.execute();
 			
 			
 			if (getCastle().getOwnerId() > 0)
 			if (getCastle().getOwnerId() > 0)
 			{
 			{
@@ -755,11 +755,11 @@ public class Siege implements Siegable
 	/** Clear all siege clans waiting for approval from database for castle */
 	/** Clear all siege clans waiting for approval from database for castle */
 	public void clearSiegeWaitingClan()
 	public void clearSiegeWaitingClan()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
 		{
 		{
-			statement.setInt(1, getCastle().getResidenceId());
-			statement.execute();
+			ps.setInt(1, getCastle().getResidenceId());
+			ps.execute();
 			
 			
 			getDefenderWaitingClans().clear();
 			getDefenderWaitingClans().clear();
 		}
 		}
@@ -982,12 +982,12 @@ public class Siege implements Siegable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
 		{
 		{
-			statement.setInt(1, getCastle().getResidenceId());
-			statement.setInt(2, clanId);
-			statement.execute();
+			ps.setInt(1, getCastle().getResidenceId());
+			ps.setInt(2, clanId);
+			ps.execute();
 			
 			
 			loadSiegeClan();
 			loadSiegeClan();
 		}
 		}
@@ -1248,8 +1248,8 @@ public class Siege implements Siegable
 	private void loadSiegeClan()
 	private void loadSiegeClan()
 	{
 	{
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
 		{
 		{
 			getAttackerClans().clear();
 			getAttackerClans().clear();
 			getDefenderClans().clear();
 			getDefenderClans().clear();
@@ -1261,8 +1261,8 @@ public class Siege implements Siegable
 				addDefender(getCastle().getOwnerId(), SiegeClanType.OWNER);
 				addDefender(getCastle().getOwnerId(), SiegeClanType.OWNER);
 			}
 			}
 			
 			
-			statement.setInt(1, getCastle().getResidenceId());
-			try (ResultSet rs = statement.executeQuery())
+			ps.setInt(1, getCastle().getResidenceId());
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				int typeId;
 				int typeId;
 				while (rs.next())
 				while (rs.next())
@@ -1359,14 +1359,14 @@ public class Siege implements Siegable
 			_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 			_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ?  WHERE id = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ?  WHERE id = ?"))
 		{
 		{
-			statement.setLong(1, getSiegeDate().getTimeInMillis());
-			statement.setLong(2, getTimeRegistrationOverDate().getTimeInMillis());
-			statement.setString(3, String.valueOf(getIsTimeRegistrationOver()));
-			statement.setInt(4, getCastle().getResidenceId());
-			statement.execute();
+			ps.setLong(1, getSiegeDate().getTimeInMillis());
+			ps.setLong(2, getTimeRegistrationOverDate().getTimeInMillis());
+			ps.setString(3, String.valueOf(getIsTimeRegistrationOver()));
+			ps.setInt(4, getCastle().getResidenceId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1388,7 +1388,7 @@ public class Siege implements Siegable
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
 			if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
 			{
 			{
@@ -1407,22 +1407,22 @@ public class Siege implements Siegable
 			
 			
 			if (!isUpdateRegistration)
 			if (!isUpdateRegistration)
 			{
 			{
-				try (PreparedStatement statement = con.prepareStatement("INSERT INTO siege_clans (clan_id,castle_id,type,castle_owner) values (?,?,?,0)"))
+				try (PreparedStatement ps = con.prepareStatement("INSERT INTO siege_clans (clan_id,castle_id,type,castle_owner) values (?,?,?,0)"))
 				{
 				{
-					statement.setInt(1, clan.getId());
-					statement.setInt(2, getCastle().getResidenceId());
-					statement.setInt(3, typeId);
-					statement.execute();
+					ps.setInt(1, clan.getId());
+					ps.setInt(2, getCastle().getResidenceId());
+					ps.setInt(3, typeId);
+					ps.execute();
 				}
 				}
 			}
 			}
 			else
 			else
 			{
 			{
-				try (PreparedStatement statement = con.prepareStatement("UPDATE siege_clans SET type = ? WHERE castle_id = ? AND clan_id = ?"))
+				try (PreparedStatement ps = con.prepareStatement("UPDATE siege_clans SET type = ? WHERE castle_id = ? AND clan_id = ?"))
 				{
 				{
-					statement.setInt(1, typeId);
-					statement.setInt(2, getCastle().getResidenceId());
-					statement.setInt(3, clan.getId());
-					statement.execute();
+					ps.setInt(1, typeId);
+					ps.setInt(2, getCastle().getResidenceId());
+					ps.setInt(3, clan.getId());
+					ps.execute();
 				}
 				}
 			}
 			}
 			
 			

+ 8 - 8
L2J_Server/java/com/l2jserver/gameserver/model/entity/clanhall/AuctionableHall.java

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.instancemanager.AuctionManager;
 import com.l2jserver.gameserver.instancemanager.AuctionManager;
@@ -218,14 +218,14 @@ public final class AuctionableHall extends ClanHall
 	@Override
 	@Override
 	public final void updateDb()
 	public final void updateDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
 		{
 		{
-			statement.setInt(1, getOwnerId());
-			statement.setLong(2, getPaidUntil());
-			statement.setInt(3, (getPaid()) ? 1 : 0);
-			statement.setInt(4, getId());
-			statement.execute();
+			ps.setInt(1, getOwnerId());
+			ps.setLong(2, getPaidUntil());
+			ps.setInt(3, (getPaid()) ? 1 : 0);
+			ps.setInt(4, getId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 13 - 13
L2J_Server/java/com/l2jserver/gameserver/model/entity/clanhall/ClanHallSiegeEngine.java

@@ -30,7 +30,7 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.data.sql.impl.ClanTable;
 import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
 import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
@@ -92,11 +92,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
 	
 	
 	public void loadAttackers()
 	public void loadAttackers()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(SQL_LOAD_ATTACKERS))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
 		{
 		{
-			statement.setInt(1, _hall.getId());
-			try (ResultSet rset = statement.executeQuery())
+			ps.setInt(1, _hall.getId());
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				while (rset.next())
 				while (rset.next())
 				{
 				{
@@ -114,11 +114,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
 	
 	
 	public final void saveAttackers()
 	public final void saveAttackers()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement delStatement = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
 		{
 		{
-			delStatement.setInt(1, _hall.getId());
-			delStatement.execute();
+			ps.setInt(1, _hall.getId());
+			ps.execute();
 			
 			
 			if (_attackers.size() > 0)
 			if (_attackers.size() > 0)
 			{
 			{
@@ -146,11 +146,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
 		if (_guards == null)
 		if (_guards == null)
 		{
 		{
 			_guards = new ArrayList<>();
 			_guards = new ArrayList<>();
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement(SQL_LOAD_GUARDS))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(SQL_LOAD_GUARDS))
 			{
 			{
-				statement.setInt(1, _hall.getId());
-				try (ResultSet rset = statement.executeQuery())
+				ps.setInt(1, _hall.getId());
+				try (ResultSet rset = ps.executeQuery())
 				{
 				{
 					while (rset.next())
 					while (rset.next())
 					{
 					{

+ 7 - 7
L2J_Server/java/com/l2jserver/gameserver/model/entity/clanhall/SiegableHall.java

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2SiegeClan;
 import com.l2jserver.gameserver.model.L2SiegeClan;
 import com.l2jserver.gameserver.model.L2SiegeClan.SiegeClanType;
 import com.l2jserver.gameserver.model.L2SiegeClan.SiegeClanType;
@@ -132,13 +132,13 @@ public final class SiegableHall extends ClanHall
 	@Override
 	@Override
 	public final void updateDb()
 	public final void updateDb()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(SQL_SAVE))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(SQL_SAVE))
 		{
 		{
-			statement.setInt(1, getOwnerId());
-			statement.setLong(2, getNextSiegeTime());
-			statement.setInt(3, getId());
-			statement.execute();
+			ps.setInt(1, getOwnerId());
+			ps.setLong(2, getNextSiegeTime());
+			ps.setInt(3, getId());
+			ps.execute();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 16 - 15
L2J_Server/java/com/l2jserver/gameserver/model/itemauction/ItemAuction.java

@@ -22,12 +22,13 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
 import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
 import com.l2jserver.gameserver.model.ItemInfo;
 import com.l2jserver.gameserver.model.ItemInfo;
@@ -52,7 +53,7 @@ public final class ItemAuction
 	private final long _startingTime;
 	private final long _startingTime;
 	private volatile long _endingTime;
 	private volatile long _endingTime;
 	private final AuctionItem _auctionItem;
 	private final AuctionItem _auctionItem;
-	private final ArrayList<ItemAuctionBid> _auctionBids;
+	private final List<ItemAuctionBid> _auctionBids;
 	private final Object _auctionStateLock;
 	private final Object _auctionStateLock;
 	
 	
 	private volatile ItemAuctionState _auctionState;
 	private volatile ItemAuctionState _auctionState;
@@ -70,10 +71,10 @@ public final class ItemAuction
 	
 	
 	public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem)
 	public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem)
 	{
 	{
-		this(auctionId, instanceId, startingTime, endingTime, auctionItem, new ArrayList<ItemAuctionBid>(), ItemAuctionState.CREATED);
+		this(auctionId, instanceId, startingTime, endingTime, auctionItem, new ArrayList<>(), ItemAuctionState.CREATED);
 	}
 	}
 	
 	
-	public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem, final ArrayList<ItemAuctionBid> auctionBids, final ItemAuctionState auctionState)
+	public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem, final List<ItemAuctionBid> auctionBids, final ItemAuctionState auctionState)
 	{
 	{
 		_auctionId = auctionId;
 		_auctionId = auctionId;
 		_instanceId = instanceId;
 		_instanceId = instanceId;
@@ -193,17 +194,17 @@ public final class ItemAuction
 	
 	
 	public final void storeMe()
 	public final void storeMe()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
 		{
 		{
-			statement.setInt(1, _auctionId);
-			statement.setInt(2, _instanceId);
-			statement.setInt(3, _auctionItem.getAuctionItemId());
-			statement.setLong(4, _startingTime);
-			statement.setLong(5, _endingTime);
-			statement.setByte(6, _auctionState.getStateId());
-			statement.setByte(7, _auctionState.getStateId());
-			statement.execute();
+			ps.setInt(1, _auctionId);
+			ps.setInt(2, _instanceId);
+			ps.setInt(3, _auctionItem.getAuctionItemId());
+			ps.setLong(4, _startingTime);
+			ps.setLong(5, _endingTime);
+			ps.setByte(6, _auctionState.getStateId());
+			ps.setByte(7, _auctionState.getStateId());
+			ps.execute();
 		}
 		}
 		catch (final SQLException e)
 		catch (final SQLException e)
 		{
 		{
@@ -227,7 +228,7 @@ public final class ItemAuction
 	final void updatePlayerBidInternal(final ItemAuctionBid bid, final boolean delete)
 	final void updatePlayerBidInternal(final ItemAuctionBid bid, final boolean delete)
 	{
 	{
 		final String query = delete ? DELETE_ITEM_AUCTION_BID : INSERT_ITEM_AUCTION_BID;
 		final String query = delete ? DELETE_ITEM_AUCTION_BID : INSERT_ITEM_AUCTION_BID;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(query))
 			PreparedStatement ps = con.prepareStatement(query))
 		{
 		{
 			ps.setInt(1, _auctionId);
 			ps.setInt(1, _auctionId);

+ 5 - 4
L2J_Server/java/com/l2jserver/gameserver/model/itemauction/ItemAuctionInstance.java

@@ -29,6 +29,7 @@ import java.util.Collection;
 import java.util.Comparator;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
@@ -40,7 +41,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.enums.ItemLocation;
@@ -163,7 +164,7 @@ public final class ItemAuctionInstance
 			throw new IllegalArgumentException("No items defined");
 			throw new IllegalArgumentException("No items defined");
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(SELECT_AUCTION_ID_BY_INSTANCE_ID))
 			PreparedStatement ps = con.prepareStatement(SELECT_AUCTION_ID_BY_INSTANCE_ID))
 		{
 		{
 			ps.setInt(1, _instanceId);
 			ps.setInt(1, _instanceId);
@@ -544,7 +545,7 @@ public final class ItemAuctionInstance
 	
 	
 	private final ItemAuction loadAuction(final int auctionId) throws SQLException
 	private final ItemAuction loadAuction(final int auctionId) throws SQLException
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			int auctionItemId = 0;
 			int auctionItemId = 0;
 			long startingTime = 0;
 			long startingTime = 0;
@@ -604,7 +605,7 @@ public final class ItemAuctionInstance
 				return null;
 				return null;
 			}
 			}
 			
 			
-			final ArrayList<ItemAuctionBid> auctionBids = new ArrayList<>();
+			final List<ItemAuctionBid> auctionBids = new ArrayList<>();
 			try (PreparedStatement ps = con.prepareStatement(SELECT_PLAYERS_ID_BY_AUCTION_ID))
 			try (PreparedStatement ps = con.prepareStatement(SELECT_PLAYERS_ID_BY_AUCTION_ID))
 			{
 			{
 				ps.setInt(1, auctionId);
 				ps.setInt(1, auctionId);

+ 7 - 7
L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java

@@ -27,7 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.xml.impl.ArmorSetsData;
 import com.l2jserver.gameserver.data.xml.impl.ArmorSetsData;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.enums.ItemLocation;
@@ -1649,13 +1649,13 @@ public abstract class Inventory extends ItemContainer
 	@Override
 	@Override
 	public void restore()
 	public void restore()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
 		{
 		{
-			statement.setInt(1, getOwnerId());
-			statement.setString(2, getBaseLocation().name());
-			statement.setString(3, getEquipLocation().name());
-			try (ResultSet inv = statement.executeQuery())
+			ps.setInt(1, getOwnerId());
+			ps.setString(2, getBaseLocation().name());
+			ps.setString(3, getEquipLocation().name());
+			try (ResultSet inv = ps.executeQuery())
 			{
 			{
 				L2ItemInstance item;
 				L2ItemInstance item;
 				while (inv.next())
 				while (inv.next())

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/ItemContainer.java

@@ -28,7 +28,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.enums.ItemLocation;
@@ -626,12 +626,12 @@ public abstract class ItemContainer
 	 */
 	 */
 	public void restore()
 	public void restore()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=?)"))
 		{
 		{
-			statement.setInt(1, getOwnerId());
-			statement.setString(2, getBaseLocation().name());
-			try (ResultSet inv = statement.executeQuery())
+			ps.setInt(1, getOwnerId());
+			ps.setString(2, getBaseLocation().name());
+			try (ResultSet inv = ps.executeQuery())
 			{
 			{
 				L2ItemInstance item;
 				L2ItemInstance item;
 				while (inv.next())
 				while (inv.next())

+ 7 - 7
L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/Mail.java

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSet;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
@@ -118,13 +118,13 @@ public class Mail extends ItemContainer
 	@Override
 	@Override
 	public void restore()
 	public void restore()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
 		{
 		{
-			statement.setInt(1, getOwnerId());
-			statement.setString(2, getBaseLocation().name());
-			statement.setInt(3, getMessageId());
-			try (ResultSet inv = statement.executeQuery())
+			ps.setInt(1, getOwnerId());
+			ps.setString(2, getBaseLocation().name());
+			ps.setInt(3, getMessageId());
+			try (ResultSet inv = ps.executeQuery())
 			{
 			{
 				L2ItemInstance item;
 				L2ItemInstance item;
 				while (inv.next())
 				while (inv.next())

+ 5 - 5
L2J_Server/java/com/l2jserver/gameserver/model/itemcontainer/PcInventory.java

@@ -27,7 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.enums.ItemLocation;
 import com.l2jserver.gameserver.model.TradeItem;
 import com.l2jserver.gameserver.model.TradeItem;
@@ -786,11 +786,11 @@ public class PcInventory extends Inventory
 	public static int[][] restoreVisibleInventory(int objectId)
 	public static int[][] restoreVisibleInventory(int objectId)
 	{
 	{
 		int[][] paperdoll = new int[31][3];
 		int[][] paperdoll = new int[31][3];
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement2 = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
 		{
 		{
-			statement2.setInt(1, objectId);
-			try (ResultSet invdata = statement2.executeQuery())
+			ps.setInt(1, objectId);
+			try (ResultSet invdata = ps.executeQuery())
 			{
 			{
 				while (invdata.next())
 				while (invdata.next())
 				{
 				{

+ 9 - 9
L2J_Server/java/com/l2jserver/gameserver/model/items/instance/L2ItemInstance.java

@@ -34,7 +34,7 @@ import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.data.xml.impl.EnchantItemOptionsData;
 import com.l2jserver.gameserver.data.xml.impl.EnchantItemOptionsData;
@@ -931,7 +931,7 @@ public final class L2ItemInstance extends L2Object
 		}
 		}
 		
 		
 		_augmentation = augmentation;
 		_augmentation = augmentation;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			updateItemAttributes(con);
 			updateItemAttributes(con);
 		}
 		}
@@ -957,7 +957,7 @@ public final class L2ItemInstance extends L2Object
 		final L2Augmentation augment = _augmentation;
 		final L2Augmentation augment = _augmentation;
 		_augmentation = null;
 		_augmentation = null;
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?"))
 			PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?"))
 		{
 		{
 			ps.setInt(1, getObjectId());
 			ps.setInt(1, getObjectId());
@@ -974,7 +974,7 @@ public final class L2ItemInstance extends L2Object
 	
 	
 	public void restoreAttributes()
 	public void restoreAttributes()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps1 = con.prepareStatement("SELECT augAttributes FROM item_attributes WHERE itemId=?");
 			PreparedStatement ps1 = con.prepareStatement("SELECT augAttributes FROM item_attributes WHERE itemId=?");
 			PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
 			PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
 		{
 		{
@@ -1172,7 +1172,7 @@ public final class L2ItemInstance extends L2Object
 	public void setElementAttr(byte element, int value)
 	public void setElementAttr(byte element, int value)
 	{
 	{
 		applyAttribute(element, value);
 		applyAttribute(element, value);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			updateItemElements(con);
 			updateItemElements(con);
 		}
 		}
@@ -1209,7 +1209,7 @@ public final class L2ItemInstance extends L2Object
 		_elementals = array;
 		_elementals = array;
 		
 		
 		String query = (element != -1) ? "DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?" : "DELETE FROM item_elementals WHERE itemId = ?";
 		String query = (element != -1) ? "DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?" : "DELETE FROM item_elementals WHERE itemId = ?";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(query))
 			PreparedStatement ps = con.prepareStatement(query))
 		{
 		{
 			if (element != -1)
 			if (element != -1)
@@ -1639,7 +1639,7 @@ public final class L2ItemInstance extends L2Object
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " + "WHERE object_id = ?"))
 			PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " + "WHERE object_id = ?"))
 		{
 		{
 			ps.setInt(1, _ownerId);
 			ps.setInt(1, _ownerId);
@@ -1674,7 +1674,7 @@ public final class L2ItemInstance extends L2Object
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"))
 			PreparedStatement ps = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"))
 		{
 		{
 			ps.setInt(1, _ownerId);
 			ps.setInt(1, _ownerId);
@@ -1720,7 +1720,7 @@ public final class L2ItemInstance extends L2Object
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?"))
 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?"))
 			{
 			{

+ 65 - 64
L2J_Server/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java

@@ -24,6 +24,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -38,7 +39,7 @@ import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
 import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
 import com.l2jserver.gameserver.instancemanager.ZoneManager;
 import com.l2jserver.gameserver.instancemanager.ZoneManager;
@@ -177,9 +178,9 @@ public class Olympiad extends ListenersContainer
 	{
 	{
 		NOBLES.clear();
 		NOBLES.clear();
 		boolean loaded = false;
 		boolean loaded = false;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA);
-			ResultSet rset = statement.executeQuery())
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement();
+			ResultSet rset = s.executeQuery(OLYMPIAD_LOAD_DATA))
 		{
 		{
 			while (rset.next())
 			while (rset.next())
 			{
 			{
@@ -250,9 +251,9 @@ public class Olympiad extends ListenersContainer
 				return;
 				return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);
-			ResultSet rset = statement.executeQuery())
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement();
+			ResultSet rset = s.executeQuery(OLYMPIAD_LOAD_NOBLES))
 		{
 		{
 			StatsSet statData;
 			StatsSet statData;
 			while (rset.next())
 			while (rset.next())
@@ -319,9 +320,9 @@ public class Olympiad extends ListenersContainer
 	{
 	{
 		NOBLES_RANK.clear();
 		NOBLES_RANK.clear();
 		Map<Integer, Integer> tmpPlace = new HashMap<>();
 		Map<Integer, Integer> tmpPlace = new HashMap<>();
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS);
-			ResultSet rset = statement.executeQuery())
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement statement = con.createStatement();
+			ResultSet rset = statement.executeQuery(GET_ALL_CLASSIFIED_NOBLESS))
 		{
 		{
 			int place = 1;
 			int place = 1;
 			while (rset.next())
 			while (rset.next())
@@ -718,7 +719,7 @@ public class Olympiad extends ListenersContainer
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
 			for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
 			{
 			{
@@ -742,38 +743,38 @@ public class Olympiad extends ListenersContainer
 				int compDoneWeekTeam = nobleInfo.getInt(COMP_DONE_WEEK_TEAM);
 				int compDoneWeekTeam = nobleInfo.getInt(COMP_DONE_WEEK_TEAM);
 				boolean toSave = nobleInfo.getBoolean("to_save");
 				boolean toSave = nobleInfo.getBoolean("to_save");
 				
 				
-				try (PreparedStatement statement = con.prepareStatement(toSave ? OLYMPIAD_SAVE_NOBLES : OLYMPIAD_UPDATE_NOBLES))
+				try (PreparedStatement ps = con.prepareStatement(toSave ? OLYMPIAD_SAVE_NOBLES : OLYMPIAD_UPDATE_NOBLES))
 				{
 				{
 					if (toSave)
 					if (toSave)
 					{
 					{
-						statement.setInt(1, charId);
-						statement.setInt(2, classId);
-						statement.setInt(3, points);
-						statement.setInt(4, compDone);
-						statement.setInt(5, compWon);
-						statement.setInt(6, compLost);
-						statement.setInt(7, compDrawn);
-						statement.setInt(8, compDoneWeek);
-						statement.setInt(9, compDoneWeekClassed);
-						statement.setInt(10, compDoneWeekNonClassed);
-						statement.setInt(11, compDoneWeekTeam);
+						ps.setInt(1, charId);
+						ps.setInt(2, classId);
+						ps.setInt(3, points);
+						ps.setInt(4, compDone);
+						ps.setInt(5, compWon);
+						ps.setInt(6, compLost);
+						ps.setInt(7, compDrawn);
+						ps.setInt(8, compDoneWeek);
+						ps.setInt(9, compDoneWeekClassed);
+						ps.setInt(10, compDoneWeekNonClassed);
+						ps.setInt(11, compDoneWeekTeam);
 						
 						
 						nobleInfo.set("to_save", false);
 						nobleInfo.set("to_save", false);
 					}
 					}
 					else
 					else
 					{
 					{
-						statement.setInt(1, points);
-						statement.setInt(2, compDone);
-						statement.setInt(3, compWon);
-						statement.setInt(4, compLost);
-						statement.setInt(5, compDrawn);
-						statement.setInt(6, compDoneWeek);
-						statement.setInt(7, compDoneWeekClassed);
-						statement.setInt(8, compDoneWeekNonClassed);
-						statement.setInt(9, compDoneWeekTeam);
-						statement.setInt(10, charId);
+						ps.setInt(1, points);
+						ps.setInt(2, compDone);
+						ps.setInt(3, compWon);
+						ps.setInt(4, compLost);
+						ps.setInt(5, compDrawn);
+						ps.setInt(6, compDoneWeek);
+						ps.setInt(7, compDoneWeekClassed);
+						ps.setInt(8, compDoneWeekNonClassed);
+						ps.setInt(9, compDoneWeekTeam);
+						ps.setInt(10, charId);
 					}
 					}
-					statement.execute();
+					ps.execute();
 				}
 				}
 			}
 			}
 		}
 		}
@@ -790,20 +791,20 @@ public class Olympiad extends ListenersContainer
 	{
 	{
 		saveNobleData();
 		saveNobleData();
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(OLYMPIAD_SAVE_DATA))
 		{
 		{
-			statement.setInt(1, _currentCycle);
-			statement.setInt(2, _period);
-			statement.setLong(3, _olympiadEnd);
-			statement.setLong(4, _validationEnd);
-			statement.setLong(5, _nextWeeklyChange);
-			statement.setInt(6, _currentCycle);
-			statement.setInt(7, _period);
-			statement.setLong(8, _olympiadEnd);
-			statement.setLong(9, _validationEnd);
-			statement.setLong(10, _nextWeeklyChange);
-			statement.execute();
+			ps.setInt(1, _currentCycle);
+			ps.setInt(2, _period);
+			ps.setLong(3, _olympiadEnd);
+			ps.setLong(4, _validationEnd);
+			ps.setLong(5, _nextWeeklyChange);
+			ps.setInt(6, _currentCycle);
+			ps.setInt(7, _period);
+			ps.setLong(8, _olympiadEnd);
+			ps.setLong(9, _validationEnd);
+			ps.setLong(10, _nextWeeklyChange);
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -831,12 +832,12 @@ public class Olympiad extends ListenersContainer
 	
 	
 	protected void updateMonthlyData()
 	protected void updateMonthlyData()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement ps1 = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
-			PreparedStatement ps2 = con.prepareStatement(OLYMPIAD_MONTH_CREATE))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s1 = con.createStatement();
+			Statement s2 = con.createStatement())
 		{
 		{
-			ps1.execute();
-			ps2.execute();
+			s1.executeUpdate(OLYMPIAD_MONTH_CLEAR);
+			s2.executeUpdate(OLYMPIAD_MONTH_CREATE);
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{
@@ -878,16 +879,16 @@ public class Olympiad extends ListenersContainer
 			_logResults.log(record);
 			_logResults.log(record);
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(OLYMPIAD_GET_HEROS))
 		{
 		{
 			StatsSet hero;
 			StatsSet hero;
 			List<StatsSet> soulHounds = new ArrayList<>();
 			List<StatsSet> soulHounds = new ArrayList<>();
 			for (int element : HERO_IDS)
 			for (int element : HERO_IDS)
 			{
 			{
-				statement.setInt(1, element);
+				ps.setInt(1, element);
 				
 				
-				try (ResultSet rset = statement.executeQuery())
+				try (ResultSet rset = ps.executeQuery())
 				{
 				{
 					if (rset.next())
 					if (rset.next())
 					{
 					{
@@ -1011,15 +1012,15 @@ public class Olympiad extends ListenersContainer
 	{
 	{
 		final List<String> names = new ArrayList<>();
 		final List<String> names = new ArrayList<>();
 		String query = Config.ALT_OLY_SHOW_MONTHLY_WINNERS ? ((classId == 132) ? GET_EACH_CLASS_LEADER_SOULHOUND : GET_EACH_CLASS_LEADER) : ((classId == 132) ? GET_EACH_CLASS_LEADER_CURRENT_SOULHOUND : GET_EACH_CLASS_LEADER_CURRENT);
 		String query = Config.ALT_OLY_SHOW_MONTHLY_WINNERS ? ((classId == 132) ? GET_EACH_CLASS_LEADER_SOULHOUND : GET_EACH_CLASS_LEADER) : ((classId == 132) ? GET_EACH_CLASS_LEADER_CURRENT_SOULHOUND : GET_EACH_CLASS_LEADER_CURRENT);
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(query))
 			PreparedStatement ps = con.prepareStatement(query))
 		{
 		{
 			ps.setInt(1, classId);
 			ps.setInt(1, classId);
-			try (ResultSet rset = ps.executeQuery())
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
-				while (rset.next())
+				while (rs.next())
 				{
 				{
-					names.add(rset.getString(CHAR_NAME));
+					names.add(rs.getString(CHAR_NAME));
 				}
 				}
 			}
 			}
 		}
 		}
@@ -1089,7 +1090,7 @@ public class Olympiad extends ListenersContainer
 	public int getLastNobleOlympiadPoints(int objId)
 	public int getLastNobleOlympiadPoints(int objId)
 	{
 	{
 		int result = 0;
 		int result = 0;
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?"))
 		{
 		{
 			ps.setInt(1, objId);
 			ps.setInt(1, objId);
@@ -1233,10 +1234,10 @@ public class Olympiad extends ListenersContainer
 	
 	
 	protected void deleteNobles()
 	protected void deleteNobles()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			Statement s = con.createStatement())
 		{
 		{
-			statement.execute();
+			s.executeUpdate(OLYMPIAD_DELETE_ALL);
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{

+ 13 - 13
L2J_Server/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameNormal.java

@@ -27,7 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.LogRecord;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.Location;
 import com.l2jserver.gameserver.model.Location;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -793,18 +793,18 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
 	
 	
 	protected static final void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
 	protected static final void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
-		{
-			statement.setInt(1, one.getObjectId());
-			statement.setInt(2, two.getObjectId());
-			statement.setInt(3, one.getBaseClass());
-			statement.setInt(4, two.getBaseClass());
-			statement.setInt(5, winner);
-			statement.setLong(6, startTime);
-			statement.setLong(7, fightTime);
-			statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
-			statement.execute();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
+		{
+			ps.setInt(1, one.getObjectId());
+			ps.setInt(2, two.getObjectId());
+			ps.setInt(3, one.getBaseClass());
+			ps.setInt(4, two.getBaseClass());
+			ps.setInt(5, winner);
+			ps.setLong(6, startTime);
+			ps.setLong(7, fightTime);
+			ps.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
+			ps.execute();
 		}
 		}
 		catch (SQLException e)
 		catch (SQLException e)
 		{
 		{

+ 16 - 16
L2J_Server/java/com/l2jserver/gameserver/model/punishment/PunishmentTask.java

@@ -27,7 +27,7 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.handler.IPunishmentHandler;
 import com.l2jserver.gameserver.handler.IPunishmentHandler;
 import com.l2jserver.gameserver.handler.PunishmentHandler;
 import com.l2jserver.gameserver.handler.PunishmentHandler;
@@ -184,17 +184,17 @@ public class PunishmentTask implements Runnable
 	{
 	{
 		if (!_isStored)
 		if (!_isStored)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
 			{
 			{
-				st.setString(1, _key);
-				st.setString(2, _affect.name());
-				st.setString(3, _type.name());
-				st.setLong(4, _expirationTime);
-				st.setString(5, _reason);
-				st.setString(6, _punishedBy);
-				st.execute();
-				try (ResultSet rset = st.getGeneratedKeys())
+				ps.setString(1, _key);
+				ps.setString(2, _affect.name());
+				ps.setString(3, _type.name());
+				ps.setLong(4, _expirationTime);
+				ps.setString(5, _reason);
+				ps.setString(6, _punishedBy);
+				ps.execute();
+				try (ResultSet rset = ps.getGeneratedKeys())
 				{
 				{
 					if (rset.next())
 					if (rset.next())
 					{
 					{
@@ -223,12 +223,12 @@ public class PunishmentTask implements Runnable
 	{
 	{
 		if (_isStored)
 		if (_isStored)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
+				PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
 			{
 			{
-				st.setLong(1, System.currentTimeMillis());
-				st.setLong(2, _id);
-				st.execute();
+				ps.setLong(1, System.currentTimeMillis());
+				ps.setLong(2, _id);
+				ps.execute();
 			}
 			}
 			catch (SQLException e)
 			catch (SQLException e)
 			{
 			{

+ 44 - 44
L2J_Server/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -35,7 +35,7 @@ import java.util.function.Predicate;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.enums.CategoryType;
 import com.l2jserver.gameserver.enums.CategoryType;
 import com.l2jserver.gameserver.enums.Race;
 import com.l2jserver.gameserver.enums.Race;
@@ -1478,7 +1478,7 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public static final void playerEnter(L2PcInstance player)
 	public static final void playerEnter(L2PcInstance player)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ?");
 			PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ?");
 			PreparedStatement invalidQuestDataVar = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ? AND var = ?");
 			PreparedStatement invalidQuestDataVar = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ? AND var = ?");
 			PreparedStatement ps1 = con.prepareStatement("SELECT name, value FROM character_quests WHERE charId = ? AND var = ?"))
 			PreparedStatement ps1 = con.prepareStatement("SELECT name, value FROM character_quests WHERE charId = ? AND var = ?"))
@@ -1567,13 +1567,13 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public final void saveGlobalQuestVar(String var, String value)
 	public final void saveGlobalQuestVar(String var, String value)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("REPLACE INTO quest_global_data (quest_name,var,value) VALUES (?,?,?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("REPLACE INTO quest_global_data (quest_name,var,value) VALUES (?,?,?)"))
 		{
 		{
-			statement.setString(1, getName());
-			statement.setString(2, var);
-			statement.setString(3, value);
-			statement.executeUpdate();
+			ps.setString(1, getName());
+			ps.setString(2, var);
+			ps.setString(3, value);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1593,12 +1593,12 @@ public class Quest extends AbstractScript implements IIdentifiable
 	public final String loadGlobalQuestVar(String var)
 	public final String loadGlobalQuestVar(String var)
 	{
 	{
 		String result = "";
 		String result = "";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("SELECT value FROM quest_global_data WHERE quest_name = ? AND var = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("SELECT value FROM quest_global_data WHERE quest_name = ? AND var = ?"))
 		{
 		{
-			statement.setString(1, getName());
-			statement.setString(2, var);
-			try (ResultSet rs = statement.executeQuery())
+			ps.setString(1, getName());
+			ps.setString(2, var);
+			try (ResultSet rs = ps.executeQuery())
 			{
 			{
 				if (rs.first())
 				if (rs.first())
 				{
 				{
@@ -1619,12 +1619,12 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public final void deleteGlobalQuestVar(String var)
 	public final void deleteGlobalQuestVar(String var)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ? AND var = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ? AND var = ?"))
 		{
 		{
-			statement.setString(1, getName());
-			statement.setString(2, var);
-			statement.executeUpdate();
+			ps.setString(1, getName());
+			ps.setString(2, var);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1637,11 +1637,11 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public final void deleteAllGlobalQuestVars()
 	public final void deleteAllGlobalQuestVars()
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ?"))
 		{
 		{
-			statement.setString(1, getName());
-			statement.executeUpdate();
+			ps.setString(1, getName());
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1657,15 +1657,15 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public static void createQuestVarInDb(QuestState qs, String var, String value)
 	public static void createQuestVarInDb(QuestState qs, String var, String value)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?"))
 		{
 		{
-			statement.setInt(1, qs.getPlayer().getObjectId());
-			statement.setString(2, qs.getQuestName());
-			statement.setString(3, var);
-			statement.setString(4, value);
-			statement.setString(5, value);
-			statement.executeUpdate();
+			ps.setInt(1, qs.getPlayer().getObjectId());
+			ps.setString(2, qs.getQuestName());
+			ps.setString(3, var);
+			ps.setString(4, value);
+			ps.setString(5, value);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1681,14 +1681,14 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public static void updateQuestVarInDb(QuestState qs, String var, String value)
 	public static void updateQuestVarInDb(QuestState qs, String var, String value)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?"))
 		{
 		{
-			statement.setString(1, value);
-			statement.setInt(2, qs.getPlayer().getObjectId());
-			statement.setString(3, qs.getQuestName());
-			statement.setString(4, var);
-			statement.executeUpdate();
+			ps.setString(1, value);
+			ps.setInt(2, qs.getPlayer().getObjectId());
+			ps.setString(3, qs.getQuestName());
+			ps.setString(4, var);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1703,13 +1703,13 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public static void deleteQuestVarInDb(QuestState qs, String var)
 	public static void deleteQuestVarInDb(QuestState qs, String var)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?"))
 		{
 		{
-			statement.setInt(1, qs.getPlayer().getObjectId());
-			statement.setString(2, qs.getQuestName());
-			statement.setString(3, var);
-			statement.executeUpdate();
+			ps.setInt(1, qs.getPlayer().getObjectId());
+			ps.setString(2, qs.getQuestName());
+			ps.setString(3, var);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -1724,7 +1724,7 @@ public class Quest extends AbstractScript implements IIdentifiable
 	 */
 	 */
 	public static void deleteQuestInDb(QuestState qs, boolean repeatable)
 	public static void deleteQuestInDb(QuestState qs, boolean repeatable)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement(repeatable ? QUEST_DELETE_FROM_CHAR_QUERY : QUEST_DELETE_FROM_CHAR_QUERY_NON_REPEATABLE_QUERY))
 			PreparedStatement ps = con.prepareStatement(repeatable ? QUEST_DELETE_FROM_CHAR_QUERY : QUEST_DELETE_FROM_CHAR_QUERY_NON_REPEATABLE_QUERY))
 		{
 		{
 			ps.setInt(1, qs.getPlayer().getObjectId());
 			ps.setInt(1, qs.getPlayer().getObjectId());

+ 13 - 13
L2J_Server/java/com/l2jserver/gameserver/model/quest/QuestState.java

@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.enums.QuestSound;
 import com.l2jserver.gameserver.enums.QuestSound;
 import com.l2jserver.gameserver.enums.QuestType;
 import com.l2jserver.gameserver.enums.QuestType;
@@ -402,13 +402,13 @@ public final class QuestState
 	// TODO: these methods should not be here, they could be used by other classes to save some variables, but they can't because they require to create a QuestState first.
 	// TODO: these methods should not be here, they could be used by other classes to save some variables, but they can't because they require to create a QuestState first.
 	public final void saveGlobalQuestVar(String var, String value)
 	public final void saveGlobalQuestVar(String var, String value)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("REPLACE INTO character_quest_global_data (charId, var, value) VALUES (?, ?, ?)"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("REPLACE INTO character_quest_global_data (charId, var, value) VALUES (?, ?, ?)"))
 		{
 		{
-			statement.setInt(1, _player.getObjectId());
-			statement.setString(2, var);
-			statement.setString(3, value);
-			statement.executeUpdate();
+			ps.setInt(1, _player.getObjectId());
+			ps.setString(2, var);
+			ps.setString(3, value);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -429,7 +429,7 @@ public final class QuestState
 	public final String getGlobalQuestVar(String var)
 	public final String getGlobalQuestVar(String var)
 	{
 	{
 		String result = "";
 		String result = "";
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement ps = con.prepareStatement("SELECT value FROM character_quest_global_data WHERE charId = ? AND var = ?"))
 			PreparedStatement ps = con.prepareStatement("SELECT value FROM character_quest_global_data WHERE charId = ? AND var = ?"))
 		{
 		{
 			ps.setInt(1, _player.getObjectId());
 			ps.setInt(1, _player.getObjectId());
@@ -455,12 +455,12 @@ public final class QuestState
 	 */
 	 */
 	public final void deleteGlobalQuestVar(String var)
 	public final void deleteGlobalQuestVar(String var)
 	{
 	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement("DELETE FROM character_quest_global_data WHERE charId = ? AND var = ?"))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement("DELETE FROM character_quest_global_data WHERE charId = ? AND var = ?"))
 		{
 		{
-			statement.setInt(1, _player.getObjectId());
-			statement.setString(2, var);
-			statement.executeUpdate();
+			ps.setInt(1, _player.getObjectId());
+			ps.setString(2, var);
+			ps.executeUpdate();
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/model/variables/AccountVariables.java

@@ -26,7 +26,7 @@ import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 
 
 /**
 /**
  * @author UnAfraid
  * @author UnAfraid
@@ -52,7 +52,7 @@ public class AccountVariables extends AbstractVariables
 	public boolean restoreMe()
 	public boolean restoreMe()
 	{
 	{
 		// Restore previous variables.
 		// Restore previous variables.
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement st = con.prepareStatement(SELECT_QUERY))
 			PreparedStatement st = con.prepareStatement(SELECT_QUERY))
 		{
 		{
 			st.setString(1, _accountName);
 			st.setString(1, _accountName);
@@ -85,7 +85,7 @@ public class AccountVariables extends AbstractVariables
 			return false;
 			return false;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			// Clear previous entries.
 			// Clear previous entries.
 			try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
 			try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

+ 6 - 6
L2J_Server/java/com/l2jserver/gameserver/model/variables/PlayerVariables.java

@@ -26,7 +26,7 @@ import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
@@ -54,11 +54,11 @@ public class PlayerVariables extends AbstractVariables
 	public boolean restoreMe()
 	public boolean restoreMe()
 	{
 	{
 		// Restore previous variables.
 		// Restore previous variables.
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement st = con.prepareStatement(SELECT_QUERY))
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
+			PreparedStatement ps = con.prepareStatement(SELECT_QUERY))
 		{
 		{
-			st.setInt(1, _objectId);
-			try (ResultSet rset = st.executeQuery())
+			ps.setInt(1, _objectId);
+			try (ResultSet rset = ps.executeQuery())
 			{
 			{
 				while (rset.next())
 				while (rset.next())
 				{
 				{
@@ -87,7 +87,7 @@ public class PlayerVariables extends AbstractVariables
 			return false;
 			return false;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			// Clear previous entries.
 			// Clear previous entries.
 			try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
 			try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

+ 4 - 4
L2J_Server/java/com/l2jserver/gameserver/network/L2GameClient.java

@@ -35,7 +35,7 @@ import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import java.util.logging.Logger;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.LoginServerThread;
 import com.l2jserver.gameserver.LoginServerThread;
 import com.l2jserver.gameserver.LoginServerThread.SessionKey;
 import com.l2jserver.gameserver.LoginServerThread.SessionKey;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
@@ -304,7 +304,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 			return -1;
 			return -1;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("SELECT clanId FROM characters WHERE charId=?"))
 			PreparedStatement statement = con.prepareStatement("SELECT clanId FROM characters WHERE charId=?"))
 		{
 		{
 			statement.setInt(1, objid);
 			statement.setInt(1, objid);
@@ -397,7 +397,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("UPDATE characters SET deletetime=0 WHERE charId=?"))
 			PreparedStatement statement = con.prepareStatement("UPDATE characters SET deletetime=0 WHERE charId=?"))
 		{
 		{
 			statement.setInt(1, objid);
 			statement.setInt(1, objid);
@@ -426,7 +426,7 @@ public final class L2GameClient extends MMOClient<MMOConnection<L2GameClient>> i
 		
 		
 		CharNameTable.getInstance().removeName(objid);
 		CharNameTable.getInstance().removeName(objid);
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = ConnectionFactory.getInstance().getConnection())
 		{
 		{
 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_contacts WHERE charId=? OR contactId=?"))
 			try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_contacts WHERE charId=? OR contactId=?"))
 			{
 			{

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestAnswerFriendInvite.java

@@ -22,7 +22,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.PreparedStatement;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.FriendPacket;
 import com.l2jserver.gameserver.network.serverpackets.FriendPacket;
@@ -66,7 +66,7 @@ public final class RequestAnswerFriendInvite extends L2GameClientPacket
 		
 		
 		if (_response == 1)
 		if (_response == 1)
 		{
 		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId) VALUES (?, ?), (?, ?)"))
 				PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId) VALUES (?, ?), (?, ?)"))
 			{
 			{
 				statement.setInt(1, requestor.getObjectId());
 				statement.setInt(1, requestor.getObjectId());

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestDestroyItem.java

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
 import com.l2jserver.Config;
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.enums.PrivateStoreType;
 import com.l2jserver.gameserver.enums.PrivateStoreType;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.model.PcCondOverride;
 import com.l2jserver.gameserver.model.PcCondOverride;
@@ -153,7 +153,7 @@ public final class RequestDestroyItem extends L2GameClientPacket
 				activeChar.getSummon().unSummon(activeChar);
 				activeChar.getSummon().unSummon(activeChar);
 			}
 			}
 			
 			
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			try (Connection con = ConnectionFactory.getInstance().getConnection();
 				PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
 				PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
 			{
 			{
 				statement.setInt(1, _objectId);
 				statement.setInt(1, _objectId);

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestFriendDel.java

@@ -22,7 +22,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.PreparedStatement;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -76,7 +76,7 @@ public final class RequestFriendDel extends L2GameClientPacket
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE (charId=? AND friendId=?) OR (charId=? AND friendId=?)"))
 			PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE (charId=? AND friendId=?) OR (charId=? AND friendId=?)"))
 		{
 		{
 			statement.setInt(1, activeChar.getObjectId());
 			statement.setInt(1, activeChar.getObjectId());

+ 2 - 2
L2J_Server/java/com/l2jserver/gameserver/network/clientpackets/RequestPetitionFeedback.java

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.SQLException;
 import java.util.logging.Level;
 import java.util.logging.Level;
 
 
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
 /**
 /**
@@ -64,7 +64,7 @@ public class RequestPetitionFeedback extends L2GameClientPacket
 			return;
 			return;
 		}
 		}
 		
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+		try (Connection con = ConnectionFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement(INSERT_FEEDBACK))
 			PreparedStatement statement = con.prepareStatement(INSERT_FEEDBACK))
 		{
 		{
 			statement.setString(1, player.getName());
 			statement.setString(1, player.getName());

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels