Refactored DatabaseFactory.

This commit is contained in:
MobiusDev
2016-01-11 21:31:45 +00:00
parent d288d505a9
commit 2684901232
140 changed files with 668 additions and 955 deletions
-6
View File
@@ -256,12 +256,6 @@ ListOfProtectedItems = 0
# Default: True # Default: True
DatabaseCleanUp = True DatabaseCleanUp = True
# The time before a database connection closes (in milliseconds)
# If a query takes longer to execute than the time defined here, the server will throw "Unclosed Connection!" error.
# If you get often this error message, try increasing this.
# Default: 60000ms
ConnectionCloseTime = 20000
# This is the interval (in minutes), that the gameserver will update a players information such as location. # This is the interval (in minutes), that the gameserver will update a players information such as location.
# The higher you set this number, there will be less character information saving so you will have less accessessing of the database and your hard drive(s). # The higher you set this number, there will be less character information saving so you will have less accessessing of the database and your hard drive(s).
# The lower you set this number, there will be more frequent character information saving so you will have more access to the database and your hard drive(s). # The lower you set this number, there will be more frequent character information saving so you will have more access to the database and your hard drive(s).
+11 -6
View File
@@ -42,27 +42,32 @@ GameserverPort = 7777
# Driver = org.hsqldb.jdbcDriver # Driver = org.hsqldb.jdbcDriver
# Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver # Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
Driver = com.mysql.jdbc.Driver Driver = com.mysql.jdbc.Driver
# Database URL # Database URL
# URL = jdbc:mysql://localhost/l2jmobius (default) # URL = jdbc:mysql://localhost/l2jmobius (default)
# URL = jdbc:hsqldb:hsql://localhost/l2jmobius # URL = jdbc:hsqldb:hsql://localhost/l2jmobius
# URL = jdbc:sqlserver://localhost/database = l2jgs/user = sa/password = # URL = jdbc:sqlserver://localhost/database = l2jmobius/user = sa/password =
URL = jdbc:mysql://localhost/l2jmobius?useUnicode=true&characterEncoding=utf-8 URL = jdbc:mysql://localhost/l2jmobius?useUnicode=true&characterEncoding=utf-8
# Database user info (default is "root" but it's not recommended) # Database user info (default is "root" but it's not recommended)
Login = root Login = root
# Database connection password # Database connection password
Password = Password =
# Database Connection Pool
# Default: C3P0
# Available: C3P0, HikariCP, BoneCP
ConnectionPool = C3P0
# Default: 500 # Default: 500
MaximumDbConnections = 500 MaximumDbConnections = 500
# Default: 0 # Default: 0
MaximumDbIdleTime = 0 MaximumDbIdleTime = 0
# The time before a database connection closes (in milliseconds)
# If a query takes longer to execute than the time defined here, the server will throw "Unclosed Connection!" error.
# If you get often this error message, try increasing this.
# Default: 60000ms
ConnectionCloseTime = 60000
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Misc Server Settings # Misc Server Settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -30,7 +30,7 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
@@ -844,7 +844,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
private static void removeAttacker(int clanId) private static void removeAttacker(int clanId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?"))
{ {
ps.setInt(1, clanId); ps.setInt(1, clanId);
@@ -858,7 +858,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
private static void addAttacker(int clanId, long count) private static void addAttacker(int clanId, long count)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)"))
{ {
ps.setInt(1, clanId); ps.setInt(1, clanId);
@@ -874,7 +874,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
@Override @Override
public void loadAttackers() public void loadAttackers()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rset = s.executeQuery("SELECT * FROM rainbowsprings_attacker_list")) ResultSet rset = s.executeQuery("SELECT * FROM rainbowsprings_attacker_list"))
{ {
@@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.ai.L2SpecialSiegeGuardAI; import com.l2jmobius.gameserver.ai.L2SpecialSiegeGuardAI;
@@ -760,7 +760,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
@Override @Override
public final void loadAttackers() public final void loadAttackers()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS)) PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{ {
ps.setInt(1, _hall.getId()); ps.setInt(1, _hall.getId());
@@ -800,7 +800,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_MEMEBERS)) PreparedStatement ps = con.prepareStatement(SQL_LOAD_MEMEBERS))
{ {
ps.setInt(1, clanId); ps.setInt(1, clanId);
@@ -820,7 +820,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
private final void saveClan(int clanId, int flag) private final void saveClan(int clanId, int flag)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_CLAN)) PreparedStatement ps = con.prepareStatement(SQL_SAVE_CLAN))
{ {
ps.setInt(1, _hall.getId()); ps.setInt(1, _hall.getId());
@@ -837,7 +837,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
private final void saveNpc(int npc, int clanId) private final void saveNpc(int npc, int clanId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_NPC)) PreparedStatement ps = con.prepareStatement(SQL_SAVE_NPC))
{ {
ps.setInt(1, npc); ps.setInt(1, npc);
@@ -852,7 +852,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
private final void saveMember(int clanId, int objectId) private final void saveMember(int clanId, int objectId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_ATTACKER)) PreparedStatement ps = con.prepareStatement(SQL_SAVE_ATTACKER))
{ {
ps.setInt(1, _hall.getId()); ps.setInt(1, _hall.getId());
@@ -868,7 +868,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
private void clearTables() private void clearTables()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(SQL_CLEAR_CLAN); PreparedStatement ps1 = con.prepareStatement(SQL_CLEAR_CLAN);
PreparedStatement ps2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS)) PreparedStatement ps2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS))
{ {
@@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.AdminData; import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2AccessLevel; import com.l2jmobius.gameserver.model.L2AccessLevel;
@@ -73,7 +73,7 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
} }
else else
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?")) PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
{ {
ps.setInt(1, lvl); ps.setInt(1, lvl);
@@ -28,7 +28,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable; import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.data.xml.impl.ClassListData; import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData; import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
@@ -576,7 +576,7 @@ public class AdminEditChar implements IAdminCommandHandler
if (player == null) if (player == null)
{ {
final String updateQuery = "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1"; final String updateQuery = "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1";
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(updateQuery)) PreparedStatement ps = con.prepareStatement(updateQuery))
{ {
ps.setString(1, playerName); ps.setString(1, playerName);
@@ -21,7 +21,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable; import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -63,7 +63,7 @@ public class AdminRepairChar implements IAdminCommandHandler
final String playerName = parts[1]; final String playerName = parts[1];
final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?"; final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement(cmd)) try (PreparedStatement ps = con.prepareStatement(cmd))
{ {
@@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.QuestManager; import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@@ -173,7 +173,7 @@ public class AdminShowQuests implements IAdminCommandHandler
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val) private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
{ {
// TODO(Zoey76): Refactor this into smaller methods and separate database access logic from HTML creation. // TODO(Zoey76): Refactor this into smaller methods and separate database access logic from HTML creation.
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
ResultSet rs; ResultSet rs;
PreparedStatement req; PreparedStatement req;
@@ -24,7 +24,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.datatables.SpawnTable; import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@@ -525,7 +525,7 @@ public class AdminTeleport implements IAdminCommandHandler
final int x = activeChar.getX(); final int x = activeChar.getX();
final int y = activeChar.getY(); final int y = activeChar.getY();
final int z = activeChar.getZ(); final int z = activeChar.getZ();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?")) PreparedStatement ps = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"))
{ {
ps.setInt(1, x); ps.setInt(1, x);
@@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.CommunityBoardHandler; import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
import com.l2jmobius.gameserver.handler.IParseBoardHandler; import com.l2jmobius.gameserver.handler.IParseBoardHandler;
@@ -61,7 +61,7 @@ public class FavoriteBoard implements IParseBoardHandler
// Load Favorite links // Load Favorite links
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html"); final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html");
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES)) PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -98,7 +98,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false; return false;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE)) PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -123,7 +123,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false; return false;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE)) PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
@@ -176,7 +176,7 @@ public final class HomeBoard implements IParseBoardHandler
private static int getFavoriteCount(L2PcInstance player) private static int getFavoriteCount(L2PcInstance player)
{ {
int count = 0; int count = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES)) PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
{ {
ps.setInt(1, player.getObjectId()); ps.setInt(1, player.getObjectId());
@@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.handler.IUserCommandHandler; import com.l2jmobius.gameserver.handler.IUserCommandHandler;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -82,7 +82,7 @@ public class ClanWarsList implements IUserCommandHandler
query = WAR_LIST; query = WAR_LIST;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query)) PreparedStatement ps = con.prepareStatement(query))
{ {
ps.setInt(1, clan.getId()); ps.setInt(1, clan.getId());
@@ -23,7 +23,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
@@ -208,7 +208,7 @@ public class Wedding implements IVoicedCommandHandler
// Check if target has player on friend list // Check if target has player on friend list
boolean foundOnFriendList = false; boolean foundOnFriendList = false;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?")) PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?"))
{ {
statement.setInt(1, ptarget.getObjectId()); statement.setInt(1, ptarget.getObjectId());
+52 -47
View File
@@ -7,6 +7,7 @@
# LAN (LOCAL area network) - typically consists of computers connected to the same router as you. # LAN (LOCAL area network) - typically consists of computers connected to the same router as you.
# WAN (WIDE area network) - typically consists of computers OUTSIDE of your router (ie. the internet). # WAN (WIDE area network) - typically consists of computers OUTSIDE of your router (ie. the internet).
# x.x.x.x - Format of an IP address. Do not include the x'es into settings. Must be real numbers. # x.x.x.x - Format of an IP address. Do not include the x'es into settings. Must be real numbers.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Networking # Networking
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -30,6 +31,43 @@ LoginHostname = 127.0.0.1
# Default: 9014 # Default: 9014
LoginPort = 9014 LoginPort = 9014
# ---------------------------------------------------------------------------
# Database
# ---------------------------------------------------------------------------
# Specify the appropriate driver and url for the database you're using.
# Examples:
# Driver = com.mysql.jdbc.Driver (default)
# Driver = org.hsqldb.jdbcDriver
# Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
Driver = com.mysql.jdbc.Driver
# Database URL
# URL = jdbc:mysql://localhost/l2jmobius (default)
# URL = jdbc:hsqldb:hsql://localhost/l2jmobius
# URL = jdbc:sqlserver://localhost/database = l2jmobius/user = sa/password =
URL = jdbc:mysql://localhost/l2jmobius?useUnicode=true&characterEncoding=utf-8
# Database user info (default is "root" but it's not recommended)
Login = root
# Database connection password
Password =
# Default: 10
MaximumDbConnections = 50
# Default: 0
MaximumDbIdleTime = 0
# The time before a database connection closes (in milliseconds)
# If a query takes longer to execute than the time defined here, the server will throw "Unclosed Connection!" error.
# If you get often this error message, try increasing this.
# Default: 60000ms
ConnectionCloseTime = 60000
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Security # Security
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -62,44 +100,9 @@ FastConnectionTime = 350
# Default: 50 # Default: 50
MaxConnectionPerIP = 50 MaxConnectionPerIP = 50
# ---------------------------------------------------------------------------
# Database
# ---------------------------------------------------------------------------
# Specify the appropriate driver and url for the database you're using.
# Examples:
# Driver = com.mysql.jdbc.Driver (default)
# Driver = org.hsqldb.jdbcDriver
# Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
Driver = com.mysql.jdbc.Driver
# Database URL
# URL = jdbc:mysql://localhost/l2jmobius (default)
# URL = jdbc:hsqldb:hsql://localhost/l2jmobius
# URL = jdbc:sqlserver://localhost/database = l2jls/user = sa/password =
URL = jdbc:mysql://localhost/l2jmobius?useUnicode=true&characterEncoding=utf-8
# Database user info (default is "root" but it's not recommended)
Login = root
# Database connection password
Password =
# Database Connection Pool
# Default: C3P0
# Available: C3P0, HikariCP, BoneCP
ConnectionPool = C3P0
# Default: 10
MaximumDbConnections = 50
# Default: 0
MaximumDbIdleTime = 0
# Connection close time.
# Default: 60000
ConnectionCloseTime = 20000
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Misc. # Misc Login Settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# If False, the license (after the login) will not be shown. # If False, the license (after the login) will not be shown.
@@ -113,20 +116,22 @@ AutoCreateAccounts = True
# Defaults to the directory where the server data are stored. # Defaults to the directory where the server data are stored.
DatapackRoot = data\ DatapackRoot = data\
# ---------------------------------------------------------------------------
# Scheduled Login Restart
# ---------------------------------------------------------------------------
# Enable disable scheduled login restart.
# Default: False
LoginRestartSchedule = False
# Time in hours.
# Default: 24
LoginRestartTime = 24
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Developer Settings # Developer Settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Default: False # Default: False
Debug = False Debug = False
# ---------------------------------------------------------------------------
# Restart LS every 24 hours?
# ---------------------------------------------------------------------------
# Enable disable scheduled login restart.
# Default: False
LoginRestartSchedule = True
# Time in hours.
# Default: 24
LoginRestartTime = 24
+4 -7
View File
@@ -482,7 +482,6 @@ public final class Config
public static int HERB_AUTO_DESTROY_TIME; public static int HERB_AUTO_DESTROY_TIME;
public static List<Integer> LIST_PROTECTED_ITEMS; public static List<Integer> LIST_PROTECTED_ITEMS;
public static boolean DATABASE_CLEAN_UP; public static boolean DATABASE_CLEAN_UP;
public static long CONNECTION_CLOSE_TIME;
public static int CHAR_STORE_INTERVAL; public static int CHAR_STORE_INTERVAL;
public static boolean LAZY_ITEMS_UPDATE; public static boolean LAZY_ITEMS_UPDATE;
public static boolean UPDATE_ITEMS_ON_CHAR_STORE; public static boolean UPDATE_ITEMS_ON_CHAR_STORE;
@@ -972,9 +971,9 @@ public final class Config
public static String DATABASE_URL; public static String DATABASE_URL;
public static String DATABASE_LOGIN; public static String DATABASE_LOGIN;
public static String DATABASE_PASSWORD; public static String DATABASE_PASSWORD;
public static String DATABASE_CONNECTION_POOL;
public static int DATABASE_MAX_CONNECTIONS; public static int DATABASE_MAX_CONNECTIONS;
public static int DATABASE_MAX_IDLE_TIME; public static int DATABASE_MAX_IDLE_TIME;
public static long CONNECTION_CLOSE_TIME;
public static int MAXIMUM_ONLINE_USERS; public static int MAXIMUM_ONLINE_USERS;
public static Pattern CHARNAME_TEMPLATE_PATTERN; public static Pattern CHARNAME_TEMPLATE_PATTERN;
public static String PET_NAME_TEMPLATE; public static String PET_NAME_TEMPLATE;
@@ -1182,12 +1181,12 @@ public final class Config
ACCEPT_ALTERNATE_ID = serverSettings.getBoolean("AcceptAlternateID", true); ACCEPT_ALTERNATE_ID = serverSettings.getBoolean("AcceptAlternateID", true);
DATABASE_DRIVER = serverSettings.getString("Driver", "com.mysql.jdbc.Driver"); DATABASE_DRIVER = serverSettings.getString("Driver", "com.mysql.jdbc.Driver");
DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jgs"); DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jmobius?useUnicode=true&characterEncoding=utf-8");
DATABASE_LOGIN = serverSettings.getString("Login", "root"); DATABASE_LOGIN = serverSettings.getString("Login", "root");
DATABASE_PASSWORD = serverSettings.getString("Password", ""); DATABASE_PASSWORD = serverSettings.getString("Password", "");
DATABASE_CONNECTION_POOL = serverSettings.getString("ConnectionPool", "C3P0");
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 500); DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 500);
DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0); DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0);
CONNECTION_CLOSE_TIME = serverSettings.getLong("ConnectionCloseTime", 60000);
Pattern charNamePattern; Pattern charNamePattern;
@@ -1833,7 +1832,6 @@ public final class Config
LIST_PROTECTED_ITEMS.add(Integer.parseInt(id)); LIST_PROTECTED_ITEMS.add(Integer.parseInt(id));
} }
DATABASE_CLEAN_UP = General.getBoolean("DatabaseCleanUp", true); DATABASE_CLEAN_UP = General.getBoolean("DatabaseCleanUp", true);
CONNECTION_CLOSE_TIME = General.getLong("ConnectionCloseTime", 60000);
CHAR_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15); CHAR_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15);
LAZY_ITEMS_UPDATE = General.getBoolean("LazyItemsUpdate", false); LAZY_ITEMS_UPDATE = General.getBoolean("LazyItemsUpdate", false);
UPDATE_ITEMS_ON_CHAR_STORE = General.getBoolean("UpdateItemsOnCharStore", false); UPDATE_ITEMS_ON_CHAR_STORE = General.getBoolean("UpdateItemsOnCharStore", false);
@@ -2930,10 +2928,9 @@ public final class Config
LOGIN_SERVER_SCHEDULE_RESTART_TIME = ServerSettings.getLong("LoginRestartTime", 24); LOGIN_SERVER_SCHEDULE_RESTART_TIME = ServerSettings.getLong("LoginRestartTime", 24);
DATABASE_DRIVER = ServerSettings.getString("Driver", "com.mysql.jdbc.Driver"); DATABASE_DRIVER = ServerSettings.getString("Driver", "com.mysql.jdbc.Driver");
DATABASE_URL = ServerSettings.getString("URL", "jdbc:mysql://localhost/l2jls"); DATABASE_URL = ServerSettings.getString("URL", "jdbc:mysql://localhost/l2jmobius?useUnicode=true&characterEncoding=utf-8");
DATABASE_LOGIN = ServerSettings.getString("Login", "root"); DATABASE_LOGIN = ServerSettings.getString("Login", "root");
DATABASE_PASSWORD = ServerSettings.getString("Password", ""); DATABASE_PASSWORD = ServerSettings.getString("Password", "");
DATABASE_CONNECTION_POOL = ServerSettings.getString("ConnectionPool", "C3P0");
DATABASE_MAX_CONNECTIONS = ServerSettings.getInt("MaximumDbConnections", 10); DATABASE_MAX_CONNECTIONS = ServerSettings.getInt("MaximumDbConnections", 10);
DATABASE_MAX_IDLE_TIME = ServerSettings.getInt("MaximumDbIdleTime", 0); DATABASE_MAX_IDLE_TIME = ServerSettings.getInt("MaximumDbIdleTime", 0);
CONNECTION_CLOSE_TIME = ServerSettings.getLong("ConnectionCloseTime", 60000); CONNECTION_CLOSE_TIME = ServerSettings.getLong("ConnectionCloseTime", 60000);
@@ -14,37 +14,32 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.l2jmobius.commons.database.pool.impl; package com.l2jmobius.commons.database;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.sql.DataSource;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.AbstractConnectionFactory;
import com.l2jmobius.commons.database.pool.IConnectionFactory;
import com.mchange.v2.c3p0.ComboPooledDataSource; import com.mchange.v2.c3p0.ComboPooledDataSource;
/** /**
* C3P0 Connection Factory implementation.<br> * Database Factory implementation.
* <b>Note that this class is not public to prevent external initialization.</b><br>
* <b>Access it through {@link ConnectionFactory} and proper configuration.</b>
* @author Zoey76 * @author Zoey76
*/ */
final class C3P0ConnectionFactory extends AbstractConnectionFactory public class DatabaseFactory
{ {
private static final Logger LOG = Logger.getLogger(C3P0ConnectionFactory.class.getName()); private static final Logger _log = Logger.getLogger(DatabaseFactory.class.getName());
private final ComboPooledDataSource _dataSource; private final ComboPooledDataSource _dataSource;
public C3P0ConnectionFactory() public DatabaseFactory()
{ {
if (Config.DATABASE_MAX_CONNECTIONS < 2) if (Config.DATABASE_MAX_CONNECTIONS < 2)
{ {
Config.DATABASE_MAX_CONNECTIONS = 2; Config.DATABASE_MAX_CONNECTIONS = 2;
LOG.warning("A minimum of " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required."); _log.warning("A minimum of 2 connections are required.");
} }
_dataSource = new ComboPooledDataSource(); _dataSource = new ComboPooledDataSource();
@@ -57,10 +52,8 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
_dataSource.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit) _dataSource.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
_dataSource.setAcquireRetryDelay(500); // 500 milliseconds wait before try to acquire connection again _dataSource.setAcquireRetryDelay(500); // 500 milliseconds wait before try to acquire connection again
_dataSource.setCheckoutTimeout(0); // 0 = wait indefinitely for new connection if pool is exhausted _dataSource.setCheckoutTimeout(0); // 0 = wait indefinitely for new connection if pool is exhausted
_dataSource.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time _dataSource.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time cause there is
// cause there is a "long" delay on acquire connection // a "long" delay on acquire connection so taking more than one connection at once will make connection pooling more effective.
// 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 // this "connection_test_table" is automatically created if not already there
_dataSource.setAutomaticTestTable("connection_test_table"); _dataSource.setAutomaticTestTable("connection_test_table");
@@ -70,19 +63,14 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
_dataSource.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec _dataSource.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
_dataSource.setMaxIdleTime(Config.DATABASE_MAX_IDLE_TIME); // 0 = idle connections never expire _dataSource.setMaxIdleTime(Config.DATABASE_MAX_IDLE_TIME); // 0 = idle connections never expire
// *THANKS* to connection testing configured above // *THANKS* to connection testing configured above but I prefer to disconnect all connections not used for more than 1 hour
// 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 // enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
_dataSource.setMaxStatementsPerConnection(100); _dataSource.setMaxStatementsPerConnection(100);
_dataSource.setBreakAfterAcquireFailure(false); // never fail if any way possible _dataSource.setBreakAfterAcquireFailure(false); // never fail if any way possible setting this to true will make c3p0 "crash"
// setting this to true will make // and refuse to work till restart thus making acquire errors "FATAL" ... we don't want that it should be possible to recover
// c3p0 "crash" and refuse to work
// till restart thus making acquire
// errors "FATAL" ... we don't want that
// it should be possible to recover
try try
{ {
_dataSource.setDriverClass(Config.DATABASE_DRIVER); _dataSource.setDriverClass(Config.DATABASE_DRIVER);
@@ -104,14 +92,25 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
{ {
e.printStackTrace(); e.printStackTrace();
} }
if (Config.DEBUG)
{
LOG.fine("Database Connection Working");
}
} }
@Override public Connection getConnection()
{
Connection con = null;
while (con == null)
{
try
{
con = _dataSource.getConnection();
}
catch (SQLException e)
{
_log.warning(getClass().getSimpleName() + ": Unable to get a connection: " + e.getMessage());
}
}
return con;
}
public void close() public void close()
{ {
try try
@@ -120,23 +119,17 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
} }
catch (Exception e) catch (Exception e)
{ {
LOG.info(e.getMessage()); _log.info(e.getMessage());
} }
} }
@Override public static DatabaseFactory getInstance()
public DataSource getDataSource()
{
return _dataSource;
}
public static IConnectionFactory getInstance()
{ {
return SingletonHolder.INSTANCE; return SingletonHolder.INSTANCE;
} }
private static class SingletonHolder private static class SingletonHolder
{ {
protected static final IConnectionFactory INSTANCE = new C3P0ConnectionFactory(); protected static final DatabaseFactory INSTANCE = new DatabaseFactory();
} }
} }
@@ -1,48 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.commons.database.pool;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Logger;
/**
* Abstract Connection Factory.
* @author Zoey76
*/
public abstract class AbstractConnectionFactory implements IConnectionFactory
{
private static final Logger LOG = Logger.getLogger(AbstractConnectionFactory.class.getName());
@Override
public Connection getConnection()
{
Connection con = null;
while (con == null)
{
try
{
con = getDataSource().getConnection();
}
catch (SQLException e)
{
LOG.warning(getClass().getSimpleName() + ": Unable to get a connection: " + e.getMessage());
}
}
return con;
}
}
@@ -1,46 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.commons.database.pool;
import java.sql.Connection;
import javax.sql.DataSource;
/**
* Connection Factory interface.
* @author Zoey76
*/
public interface IConnectionFactory
{
/**
* Gets the data source.
* @return the data source
*/
DataSource getDataSource();
/**
* Gets a connection from the pool.
* @return a connection
*/
Connection getConnection();
/**
* Closes the data source.<br>
* <i>Same as shutdown.</i>
*/
void close();
}
@@ -1,64 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.commons.database.pool.impl;
import java.util.logging.Logger;
import javax.sql.DataSource;
import com.l2jmobius.commons.database.pool.AbstractConnectionFactory;
import com.l2jmobius.commons.database.pool.IConnectionFactory;
/**
* BoneCP Connection Factory implementation.<br>
* <b>Note that this class is not public to prevent external initialization.</b><br>
* <b>Access it through {@link ConnectionFactory} and proper configuration.</b>
* @author Zoey76
*/
final class BoneCPConnectionFactory extends AbstractConnectionFactory
{
private static final Logger LOG = Logger.getLogger(BoneCPConnectionFactory.class.getName());
private final DataSource _dataSource = null;
public BoneCPConnectionFactory()
{
LOG.severe("BoneCP is not supported yet, nothing is going to work!");
}
@Override
public void close()
{
throw new UnsupportedOperationException("BoneCP is not supported yet!");
}
@Override
public DataSource getDataSource()
{
return _dataSource;
}
public static IConnectionFactory getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final IConnectionFactory INSTANCE = new BoneCPConnectionFactory();
}
}
@@ -1,59 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.commons.database.pool.impl;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.IConnectionFactory;
/**
* Connection Factory implementation.
* @author Zoey76
*/
public class ConnectionFactory
{
public static IConnectionFactory getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final IConnectionFactory INSTANCE;
static
{
switch (Config.DATABASE_CONNECTION_POOL)
{
default:
case "C3P0":
{
INSTANCE = new C3P0ConnectionFactory();
break;
}
case "HikariCP":
{
INSTANCE = new HikariCPConnectionFactory();
break;
}
case "BoneCP":
{
INSTANCE = new BoneCPConnectionFactory();
break;
}
}
}
}
}
@@ -1,64 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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.l2jmobius.commons.database.pool.impl;
import java.util.logging.Logger;
import javax.sql.DataSource;
import com.l2jmobius.commons.database.pool.AbstractConnectionFactory;
import com.l2jmobius.commons.database.pool.IConnectionFactory;
/**
* HikariCP Connection Factory implementation.<br>
* <b>Note that this class is not public to prevent external initialization.</b><br>
* <b>Access it through {@link ConnectionFactory} and proper configuration.</b>
* @author Zoey76
*/
final class HikariCPConnectionFactory extends AbstractConnectionFactory
{
private static final Logger LOG = Logger.getLogger(HikariCPConnectionFactory.class.getName());
private final DataSource _dataSource = null;
public HikariCPConnectionFactory()
{
LOG.severe("HikariCP is not supported yet, nothing is going to work!");
}
@Override
public void close()
{
throw new UnsupportedOperationException("HikariCP is not supported yet!");
}
@Override
public DataSource getDataSource()
{
return _dataSource;
}
public static IConnectionFactory getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final IConnectionFactory INSTANCE = new HikariCPConnectionFactory();
}
}
@@ -30,7 +30,7 @@ import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.Server; import com.l2jmobius.Server;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.mmocore.SelectorConfig; import com.l2jmobius.commons.mmocore.SelectorConfig;
import com.l2jmobius.commons.mmocore.SelectorThread; import com.l2jmobius.commons.mmocore.SelectorThread;
import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.cache.HtmCache;
@@ -480,7 +480,7 @@ public final class GameServer
// Initialize config // Initialize config
Config.load(); Config.load();
printSection("Database"); printSection("Database");
ConnectionFactory.getInstance(); DatabaseFactory.getInstance();
gameServer = new GameServer(); gameServer = new GameServer();
if (Config.IS_TELNET_ENABLED) if (Config.IS_TELNET_ENABLED)
@@ -43,7 +43,7 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.L2GameClient;
@@ -580,7 +580,7 @@ public class LoginServerThread extends Thread
{ {
int chars = 0; int chars = 0;
final List<Long> charToDel = new ArrayList<>(); final List<Long> charToDel = new ArrayList<>();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -20,7 +20,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
import com.l2jmobius.gameserver.datatables.BotReportTable; import com.l2jmobius.gameserver.datatables.BotReportTable;
@@ -263,8 +263,8 @@ public class Shutdown extends Thread
// commit data, last chance // commit data, last chance
try try
{ {
ConnectionFactory.getInstance().close(); DatabaseFactory.getInstance().close();
_log.info("L2Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms)."); _log.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
} }
catch (Throwable t) catch (Throwable t)
{ {
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager; import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
@@ -91,7 +91,7 @@ public final class Forum
private void load() private void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -112,7 +112,7 @@ public final 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -137,7 +137,7 @@ public final class Forum
private void getChildren() private void getChildren()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -215,7 +215,7 @@ public final class Forum
public void insertIntoDb() public void insertIntoDb()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.Manager.PostBBSManager; import com.l2jmobius.gameserver.communitybbs.Manager.PostBBSManager;
/** /**
@@ -76,7 +76,7 @@ public class Post
public void insertindb(CPost cp) public void insertindb(CPost cp)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -102,7 +102,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -120,7 +120,7 @@ public class Post
*/ */
private void load(Topic t) private void load(Topic t)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -153,7 +153,7 @@ public class Post
public void updatetxt(int i) public void updatetxt(int i)
{ {
final CPost cp = getCPost(i); final CPost cp = getCPost(i);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
{ {
ps.setString(1, cp.postTxt); ps.setString(1, cp.postTxt);
@@ -21,7 +21,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager; import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
public class Topic public class Topic
@@ -71,7 +71,7 @@ public class Topic
public void insertindb() public void insertindb()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -129,7 +129,7 @@ public class Topic
{ {
TopicBBSManager.getInstance().delTopic(this); TopicBBSManager.getInstance().delTopic(this);
f.rmTopicByID(getID()); f.rmTopicByID(getID());
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.BB.Forum; import com.l2jmobius.gameserver.communitybbs.BB.Forum;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -39,7 +39,7 @@ public class ForumsBBSManager extends BaseBBSManager
*/ */
protected ForumsBBSManager() protected ForumsBBSManager()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -25,7 +25,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.enums.ChatType; import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.Announcement; import com.l2jmobius.gameserver.model.announce.Announcement;
@@ -52,7 +52,7 @@ public final class AnnouncementsTable
private void load() private void load()
{ {
_announcements.clear(); _announcements.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement(); Statement st = con.createStatement();
ResultSet rset = st.executeQuery("SELECT * FROM announcements")) ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
{ {
@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/** /**
@@ -99,7 +99,7 @@ public class CharNameTable
int id = -1; int id = -1;
int accessLevel = 0; int accessLevel = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -145,7 +145,7 @@ public class CharNameTable
return null; return null;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -181,7 +181,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -199,7 +199,7 @@ public class CharNameTable
public int getAccountCharacterCount(String account) public int getAccountCharacterCount(String account)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -220,7 +220,7 @@ public class CharNameTable
public int getLevelById(int objectId) public int getLevelById(int objectId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT level FROM characters WHERE charId = ?")) PreparedStatement ps = con.prepareStatement("SELECT level FROM characters WHERE charId = ?"))
{ {
ps.setInt(1, objectId); ps.setInt(1, objectId);
@@ -241,7 +241,7 @@ public class CharNameTable
public int getClassIdById(int objectId) public int getClassIdById(int objectId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT classid FROM characters WHERE charId = ?")) PreparedStatement ps = con.prepareStatement("SELECT classid FROM characters WHERE charId = ?"))
{ {
ps.setInt(1, objectId); ps.setInt(1, objectId);
@@ -262,7 +262,7 @@ public class CharNameTable
private void loadAll() private void loadAll()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.datatables.SkillData;
@@ -70,7 +70,7 @@ public class CharSummonTable
{ {
if (Config.RESTORE_SERVITOR_ON_RECONNECT) if (Config.RESTORE_SERVITOR_ON_RECONNECT)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_SUMMONS)) ResultSet rs = s.executeQuery(INIT_SUMMONS))
{ {
@@ -87,7 +87,7 @@ public class CharSummonTable
if (Config.RESTORE_PET_ON_RECONNECT) if (Config.RESTORE_PET_ON_RECONNECT)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_PET)) ResultSet rs = s.executeQuery(INIT_PET))
{ {
@@ -111,7 +111,7 @@ public class CharSummonTable
return !v.isEmpty() ? v : null; return !v.isEmpty() ? v : null;
}); });
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON)) PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -181,7 +181,7 @@ public class CharSummonTable
public void restoreServitor(L2PcInstance activeChar) public void restoreServitor(L2PcInstance activeChar)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(LOAD_SUMMON)) PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -227,7 +227,7 @@ public class CharSummonTable
_servitors.computeIfAbsent(summon.getOwner().getObjectId(), k -> ConcurrentHashMap.newKeySet()).add(summon.getObjectId()); _servitors.computeIfAbsent(summon.getOwner().getObjectId(), k -> ConcurrentHashMap.newKeySet()).add(summon.getObjectId());
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
import com.l2jmobius.gameserver.enums.UserInfoType; import com.l2jmobius.gameserver.enums.UserInfoType;
@@ -80,7 +80,7 @@ public class ClanTable
L2Clan clan; L2Clan clan;
// Count the clans // Count the clans
int clanCount = 0; int clanCount = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -273,7 +273,7 @@ public class ClanTable
_clans.remove(clanId); _clans.remove(clanId);
IdFactory.getInstance().releaseId(clanId); IdFactory.getInstance().releaseId(clanId);
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.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=?"))
{ {
@@ -390,7 +390,7 @@ public class ClanTable
clan2.setAttackerClan(clan1); clan2.setAttackerClan(clan1);
clan1.broadcastClanStatus(); clan1.broadcastClanStatus();
clan2.broadcastClanStatus(); clan2.broadcastClanStatus();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -432,7 +432,7 @@ public class ClanTable
clan1.broadcastClanStatus(); clan1.broadcastClanStatus();
clan2.broadcastClanStatus(); clan2.broadcastClanStatus();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -474,7 +474,7 @@ public class ClanTable
private void restorewars() private void restorewars()
{ {
L2Clan clan1, clan2; L2Clan clan1, clan2;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Crest; import com.l2jmobius.gameserver.model.L2Crest;
import com.l2jmobius.gameserver.model.L2Crest.CrestType; import com.l2jmobius.gameserver.model.L2Crest.CrestType;
@@ -72,7 +72,7 @@ public final class CrestTable
} }
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -163,7 +163,7 @@ public final class CrestTable
*/ */
public L2Crest createCrest(byte[] data, CrestType crestType) public L2Crest createCrest(byte[] data, CrestType crestType)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
{ {
final L2Crest crest = new L2Crest(getNextId(), data, crestType); final L2Crest crest = new L2Crest(getNextId(), data, crestType);
@@ -196,7 +196,7 @@ public final class CrestTable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.holders.ItemHolder; import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder; import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -88,7 +88,7 @@ public class NpcBufferTable
protected NpcBufferTable() protected NpcBufferTable()
{ {
int skillCount = 0; int skillCount = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -135,7 +135,7 @@ public class NpcBufferTable
if (Config.CUSTOM_NPCBUFFER_TABLES) if (Config.CUSTOM_NPCBUFFER_TABLES)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -25,7 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.LoginServerThread; import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.enums.PrivateStoreType; import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.L2ManufactureItem; import com.l2jmobius.gameserver.model.L2ManufactureItem;
@@ -51,7 +51,7 @@ public class OfflineTradersTable
public void storeOffliners() public void storeOffliners()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -153,7 +153,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement stm = con.createStatement(); Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS)) ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS))
{ {
@@ -294,7 +294,7 @@ public class OfflineTradersTable
public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall) public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER);
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER); PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER);
PreparedStatement stm3 = con.prepareStatement(SAVE_ITEMS); PreparedStatement stm3 = con.prepareStatement(SAVE_ITEMS);
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable; import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
public class PetNameTable public class PetNameTable
@@ -42,7 +42,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.actor.L2Summon;
@@ -45,7 +45,7 @@ public class SummonSkillsTable
{ {
_skillTrees.clear(); _skillTrees.clear();
int count = 0; int count = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -25,7 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2TeleportLocation; import com.l2jmobius.gameserver.model.L2TeleportLocation;
public class TeleportLocationTable public class TeleportLocationTable
@@ -42,7 +42,7 @@ public class TeleportLocationTable
public void reloadAll() public void reloadAll()
{ {
_teleports.clear(); _teleports.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -71,7 +71,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -25,7 +25,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2Territory; import com.l2jmobius.gameserver.model.L2Territory;
import com.l2jmobius.gameserver.model.Location; import com.l2jmobius.gameserver.model.Location;
@@ -72,7 +72,7 @@ public class TerritoryTable
public void load() public void load()
{ {
_territory.clear(); _territory.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -30,7 +30,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
import com.l2jmobius.gameserver.model.buylist.Product; import com.l2jmobius.gameserver.model.buylist.Product;
@@ -64,7 +64,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`")) ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`"))
{ {
@@ -36,7 +36,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@@ -109,7 +109,7 @@ public final class BotReportTable
*/ */
private void loadReportedCharData() private void loadReportedCharData()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -178,7 +178,7 @@ public final class BotReportTable
*/ */
public void saveReportedCharData() public void saveReportedCharData()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -30,7 +30,7 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData; import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.engines.DocumentEngine; import com.l2jmobius.gameserver.engines.DocumentEngine;
@@ -362,7 +362,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -34,7 +34,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager; import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager; import com.l2jmobius.gameserver.instancemanager.ZoneManager;
@@ -255,7 +255,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -416,7 +416,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -451,7 +451,7 @@ public final class SpawnTable implements IXmlReader
if (updateDb) if (updateDb)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
/** /**
* 18.8.2010 - JIV: Disabling until someone update it * 18.8.2010 - JIV: Disabling until someone update it
@@ -39,7 +39,7 @@ public class CompactionIDFactory extends IdFactory
_curOID = FIRST_OID; _curOID = FIRST_OID;
_freeSize = 0; _freeSize = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final Integer[] tmp_obj_ids = extractUsedObjectIDTable(); final Integer[] tmp_obj_ids = extractUsedObjectIDTable();
@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
/** /**
* This class ... * This class ...
@@ -181,7 +181,7 @@ public abstract class IdFactory
*/ */
private void setAllCharacterOffline() private void setAllCharacterOffline()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
s.executeUpdate("UPDATE characters SET online = 0"); s.executeUpdate("UPDATE characters SET online = 0");
@@ -198,7 +198,7 @@ public abstract class IdFactory
*/ */
private void cleanUpDB() private void cleanUpDB()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement stmt = con.createStatement()) Statement stmt = con.createStatement())
{ {
final long cleanupStart = System.currentTimeMillis(); final long cleanupStart = System.currentTimeMillis();
@@ -310,7 +310,7 @@ public abstract class IdFactory
private void cleanInvalidWeddings() private void cleanInvalidWeddings()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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)");
@@ -325,7 +325,7 @@ public abstract class IdFactory
private void cleanUpTimeStamps() private void cleanUpTimeStamps()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
int cleanCount = 0; int cleanCount = 0;
for (String line : TIMESTAMPS_CLEAN) for (String line : TIMESTAMPS_CLEAN)
@@ -351,7 +351,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
String extractUsedObjectIdsQuery = ""; String extractUsedObjectIdsQuery = "";
@@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.util.Stack; import java.util.Stack;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
/** /**
* This class ... * This class ...
@@ -42,7 +42,7 @@ public class StackIDFactory extends IdFactory
_curOID = FIRST_OID; _curOID = FIRST_OID;
_tempOID = FIRST_OID; _tempOID = FIRST_OID;
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
// con.createStatement().execute("drop table if exists tmp_obj_id"); // con.createStatement().execute("drop table if exists tmp_obj_id");
@@ -26,7 +26,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.AirShipTeleportList; import com.l2jmobius.gameserver.model.AirShipTeleportList;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.VehiclePathPoint; import com.l2jmobius.gameserver.model.VehiclePathPoint;
@@ -169,7 +169,7 @@ public class AirShipManager
_airShipsInfo.put(ownerId, info); _airShipsInfo.put(ownerId, info);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_DB)) PreparedStatement ps = con.prepareStatement(ADD_DB))
{ {
ps.setInt(1, ownerId); ps.setInt(1, ownerId);
@@ -265,7 +265,7 @@ public class AirShipManager
private void load() private void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(LOAD_DB)) ResultSet rs = s.executeQuery(LOAD_DB))
{ {
@@ -296,7 +296,7 @@ public class AirShipManager
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"));
@@ -24,7 +24,7 @@ import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -52,7 +52,7 @@ public final class CHSiegeManager
private final void loadClanHalls() private final void loadClanHalls()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(SQL_LOAD_HALLS)) ResultSet rs = s.executeQuery(SQL_LOAD_HALLS))
{ {
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.InstanceListManager; import com.l2jmobius.gameserver.InstanceListManager;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2ClanMember; import com.l2jmobius.gameserver.model.L2ClanMember;
@@ -250,7 +250,7 @@ public final class CastleManager implements InstanceListManager
} }
} }
// else offline-player circlet removal // else offline-player circlet removal
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -267,7 +267,7 @@ public final class CastleManager implements InstanceListManager
@Override @Override
public void loadInstances() public void loadInstances()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.enums.ManorMode; import com.l2jmobius.gameserver.enums.ManorMode;
import com.l2jmobius.gameserver.model.CropProcure; import com.l2jmobius.gameserver.model.CropProcure;
@@ -164,7 +164,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
private final void loadDb() private final void loadDb()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
{ {
@@ -442,7 +442,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -478,7 +478,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -512,7 +512,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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)
@@ -532,7 +532,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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)
@@ -605,7 +605,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
@Override @Override
public final boolean storeMe() public final boolean storeMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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");
@@ -703,7 +703,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 = ?"))
{ {
@@ -33,7 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.clan.entry.PledgeApplicantInfo; import com.l2jmobius.gameserver.model.clan.entry.PledgeApplicantInfo;
import com.l2jmobius.gameserver.model.clan.entry.PledgeRecruitInfo; import com.l2jmobius.gameserver.model.clan.entry.PledgeRecruitInfo;
@@ -91,7 +91,7 @@ public class ClanEntryManager
private final void load() private final void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit")) ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit"))
{ {
@@ -106,7 +106,7 @@ public class ClanEntryManager
_log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage()); _log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage());
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId")) ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId"))
{ {
@@ -122,7 +122,7 @@ public class ClanEntryManager
_log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage()); _log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage());
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId")) ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId"))
{ {
@@ -168,7 +168,7 @@ public class ClanEntryManager
{ {
final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId); final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT)) PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT))
{ {
statement.setInt(1, playerId); statement.setInt(1, playerId);
@@ -189,7 +189,7 @@ public class ClanEntryManager
{ {
_applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info); _applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT)) PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT))
{ {
statement.setInt(1, info.getPlayerId()); statement.setInt(1, info.getPlayerId());
@@ -216,7 +216,7 @@ public class ClanEntryManager
{ {
if (!_playerLocked.containsKey(playerId)) if (!_playerLocked.containsKey(playerId))
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST)) PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST))
{ {
statement.setInt(1, info.getPlayerId()); statement.setInt(1, info.getPlayerId());
@@ -237,7 +237,7 @@ public class ClanEntryManager
{ {
if (_waitingList.containsKey(playerId)) if (_waitingList.containsKey(playerId))
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST)) PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST))
{ {
statement.setInt(1, playerId); statement.setInt(1, playerId);
@@ -258,7 +258,7 @@ public class ClanEntryManager
{ {
if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId)) if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_CLAN_RECRUIT)) PreparedStatement statement = con.prepareStatement(INSERT_CLAN_RECRUIT))
{ {
statement.setInt(1, info.getClanId()); statement.setInt(1, info.getClanId());
@@ -280,7 +280,7 @@ public class ClanEntryManager
{ {
if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId)) if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CLAN_RECRUIT)) PreparedStatement statement = con.prepareStatement(UPDATE_CLAN_RECRUIT))
{ {
statement.setInt(1, info.getKarma()); statement.setInt(1, info.getKarma());
@@ -302,7 +302,7 @@ public class ClanEntryManager
{ {
if (_clanList.containsKey(clanId)) if (_clanList.containsKey(clanId))
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_CLAN_RECRUIT)) PreparedStatement statement = con.prepareStatement(DELETE_CLAN_RECRUIT))
{ {
statement.setInt(1, clanId); statement.setInt(1, clanId);
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.entity.Auction; import com.l2jmobius.gameserver.model.entity.Auction;
/** /**
@@ -98,7 +98,7 @@ public final class ClanHallAuctionManager
private final void load() private final void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -163,7 +163,7 @@ public final class ClanHallAuctionManager
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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]);
@@ -25,7 +25,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@@ -62,7 +62,7 @@ public final class ClanHallManager
/** Load All Clan Hall */ /** Load All Clan Hall */
private final void load() private final void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -34,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.enums.ItemLocation; import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.enums.MailType; import com.l2jmobius.gameserver.enums.MailType;
@@ -79,7 +79,7 @@ public final class CommissionManager
protected CommissionManager() protected CommissionManager()
{ {
final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>(); final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS)) try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS))
{ {
@@ -253,7 +253,7 @@ public final class CommissionManager
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS)) PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS))
{ {
final Instant startTime = Instant.now(); final Instant startTime = Instant.now();
@@ -406,7 +406,7 @@ public final class CommissionManager
*/ */
private boolean deleteItemFromDB(long commissionId) private boolean deleteItemFromDB(long commissionId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM)) PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM))
{ {
ps.setLong(1, commissionId); ps.setLong(1, commissionId);
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Couple; import com.l2jmobius.gameserver.model.entity.Couple;
@@ -51,7 +51,7 @@ public final class CoupleManager
private final void load() private final void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.CursedWeapon; import com.l2jmobius.gameserver.model.CursedWeapon;
import com.l2jmobius.gameserver.model.actor.L2Attackable; import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character; import com.l2jmobius.gameserver.model.actor.L2Character;
@@ -170,7 +170,7 @@ public final class CursedWeaponsManager
private final void restore() private final void restore()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -203,7 +203,7 @@ public final class CursedWeaponsManager
// or a lost-child entry in the cursed weapons table, without a corresponding one in items... // 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 // Retrieve the L2PcInstance from the characters table of the database
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?")) PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
{ {
for (CursedWeapon cw : _cursedWeapons.values()) for (CursedWeapon cw : _cursedWeapons.values())
@@ -369,7 +369,7 @@ public final class CursedWeaponsManager
public static void removeFromDb(int itemId) public static void removeFromDb(int itemId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/** /**
@@ -46,7 +46,7 @@ public class FactionManager
private void loadAll() private void loadAll()
{ {
_playerFactions.clear(); _playerFactions.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters")) ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
{ {
@@ -76,7 +76,7 @@ public class FactionManager
return factionId; return factionId;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?")) PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
{ {
ps.setInt(1, id); ps.setInt(1, id);
@@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
@@ -99,7 +99,7 @@ public class FishingChampionshipManager
{ {
_enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0); _enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0);
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final PreparedStatement statement = con.prepareStatement(SELECT); final PreparedStatement statement = con.prepareStatement(SELECT);
final ResultSet rs = statement.executeQuery(); final ResultSet rs = statement.executeQuery();
@@ -379,7 +379,7 @@ public class FishingChampionshipManager
{ {
GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate); GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate);
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement(DELETE); PreparedStatement statement = con.prepareStatement(DELETE);
statement.execute(); statement.execute();
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.InstanceListManager; import com.l2jmobius.gameserver.InstanceListManager;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@@ -160,7 +160,7 @@ public final class FortManager implements InstanceListManager
@Override @Override
public void loadInstances() public void loadInstances()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -26,7 +26,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2Spawn; import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.entity.Fort; import com.l2jmobius.gameserver.model.entity.Fort;
@@ -104,7 +104,7 @@ public final class FortSiegeGuardManager
void loadSiegeGuard() void loadSiegeGuard()
{ {
_siegeGuards.clear(); _siegeGuards.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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();
@@ -32,7 +32,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.CombatFlag; import com.l2jmobius.gameserver.model.CombatFlag;
import com.l2jmobius.gameserver.model.FortSiegeSpawn; import com.l2jmobius.gameserver.model.FortSiegeSpawn;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
@@ -86,7 +86,7 @@ public final class FortSiegeManager
} }
boolean register = false; boolean register = false;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -33,7 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.DoorData; import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.datatables.SpawnTable; import com.l2jmobius.gameserver.datatables.SpawnTable;
@@ -417,7 +417,7 @@ public final class FourSepulchersManager
{ {
_mysteriousBoxSpawns.clear(); _mysteriousBoxSpawns.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -474,7 +474,7 @@ public final class FourSepulchersManager
_physicalMonsters.clear(); _physicalMonsters.clear();
int loaded = 0; int loaded = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -521,7 +521,7 @@ public final class FourSepulchersManager
_magicalMonsters.clear(); _magicalMonsters.clear();
int loaded = 0; int loaded = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -570,7 +570,7 @@ public final class FourSepulchersManager
_archonSpawned.clear(); _archonSpawned.clear();
int loaded = 0; int loaded = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -621,7 +621,7 @@ public final class FourSepulchersManager
_emperorsGraveNpcs.clear(); _emperorsGraveNpcs.clear();
int loaded = 0; int loaded = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -25,7 +25,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.variables.AbstractVariables; import com.l2jmobius.gameserver.model.variables.AbstractVariables;
/** /**
@@ -50,7 +50,7 @@ public final class GlobalVariablesManager extends AbstractVariables
public boolean restoreMe() public boolean restoreMe()
{ {
// Restore previous variables. // Restore previous variables.
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement(); Statement st = con.createStatement();
ResultSet rset = st.executeQuery(SELECT_QUERY)) ResultSet rset = st.executeQuery(SELECT_QUERY))
{ {
@@ -81,7 +81,7 @@ public final class GlobalVariablesManager extends AbstractVariables
return false; return false;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement del = con.createStatement(); Statement del = con.createStatement();
PreparedStatement st = con.prepareStatement(INSERT_QUERY)) PreparedStatement st = con.prepareStatement(INSERT_QUERY))
{ {
@@ -113,7 +113,7 @@ public final class GlobalVariablesManager extends AbstractVariables
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement del = con.createStatement()) Statement del = con.createStatement())
{ {
del.execute(DELETE_QUERY); del.execute(DELETE_QUERY);
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.instancemanager.tasks.GrandBossManagerStoreTask; import com.l2jmobius.gameserver.instancemanager.tasks.GrandBossManagerStoreTask;
@@ -73,7 +73,7 @@ public final class GrandBossManager implements IStorable
private void init() private void init()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -127,7 +127,7 @@ public final class GrandBossManager implements IStorable
zones.put(zoneId, new ArrayList<>()); zones.put(zoneId, new ArrayList<>());
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -235,7 +235,7 @@ public final class GrandBossManager implements IStorable
@Override @Override
public boolean storeMe() public boolean storeMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
s.executeUpdate(DELETE_GRAND_BOSS_LIST); s.executeUpdate(DELETE_GRAND_BOSS_LIST);
@@ -308,7 +308,7 @@ public final class GrandBossManager implements IStorable
private void updateDb(int bossId, boolean statusOnly) private void updateDb(int bossId, boolean statusOnly)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final L2GrandBossInstance boss = BOSSES.get(bossId); final L2GrandBossInstance boss = BOSSES.get(bossId);
final StatsSet info = _storedInfo.get(bossId); final StatsSet info = _storedInfo.get(bossId);
@@ -28,7 +28,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Instance; import com.l2jmobius.gameserver.model.entity.Instance;
import com.l2jmobius.gameserver.model.instancezone.InstanceWorld; import com.l2jmobius.gameserver.model.instancezone.InstanceWorld;
@@ -121,7 +121,7 @@ public final class InstanceManager implements IXmlReader
restoreInstanceTimes(playerObjId); restoreInstanceTimes(playerObjId);
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_INSTANCE_TIME)) PreparedStatement ps = con.prepareStatement(ADD_INSTANCE_TIME))
{ {
ps.setInt(1, playerObjId); ps.setInt(1, playerObjId);
@@ -143,7 +143,7 @@ public final class InstanceManager implements IXmlReader
*/ */
public void deleteInstanceTime(int playerObjId, int id) public void deleteInstanceTime(int playerObjId, int id)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME)) PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
{ {
ps.setInt(1, playerObjId); ps.setInt(1, playerObjId);
@@ -167,7 +167,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_INSTANCE_TIMES)) PreparedStatement ps = con.prepareStatement(RESTORE_INSTANCE_TIMES))
{ {
ps.setInt(1, playerObjId); ps.setInt(1, playerObjId);
@@ -35,7 +35,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.itemauction.ItemAuctionInstance; import com.l2jmobius.gameserver.model.itemauction.ItemAuctionInstance;
/** /**
@@ -58,7 +58,7 @@ public final class ItemAuctionManager
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1")) ResultSet rs = s.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1"))
{ {
@@ -136,7 +136,7 @@ public final class ItemAuctionManager
public static final void deleteAuction(final int auctionId) public static final void deleteAuction(final int auctionId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?")) try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?"))
{ {
@@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ItemsAutoDestroy; import com.l2jmobius.gameserver.ItemsAutoDestroy;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
@@ -80,7 +80,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(str)) PreparedStatement ps = con.prepareStatement(str))
{ {
ps.setLong(1, System.currentTimeMillis()); ps.setLong(1, System.currentTimeMillis());
@@ -93,7 +93,7 @@ public final class ItemsOnGroundManager implements Runnable
} }
// Add items to world // Add items to world
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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;
@@ -179,7 +179,7 @@ public final class ItemsOnGroundManager implements Runnable
public void emptyTable() public void emptyTable()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
s.executeUpdate("DELETE FROM itemsonground"); s.executeUpdate("DELETE FROM itemsonground");
@@ -205,7 +205,7 @@ public final class ItemsOnGroundManager implements Runnable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)")) 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)
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.idfactory.IdFactory; import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.tasks.MessageDeletionTask; import com.l2jmobius.gameserver.instancemanager.tasks.MessageDeletionTask;
@@ -56,7 +56,7 @@ public final class MailManager
private void load() private void load()
{ {
int count = 0; int count = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -171,7 +171,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = Message.getStatement(msg, con)) PreparedStatement ps = Message.getStatement(msg, con))
{ {
ps.execute(); ps.execute();
@@ -193,7 +193,7 @@ public final class MailManager
public final void markAsReadInDb(int msgId) public final void markAsReadInDb(int msgId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -207,7 +207,7 @@ public final class MailManager
public final void markAsDeletedBySenderInDb(int msgId) public final void markAsDeletedBySenderInDb(int msgId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -221,7 +221,7 @@ public final class MailManager
public final void markAsDeletedByReceiverInDb(int msgId) public final void markAsDeletedByReceiverInDb(int msgId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -235,7 +235,7 @@ public final class MailManager
public final void removeAttachmentsInDb(int msgId) public final void removeAttachmentsInDb(int msgId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -249,7 +249,7 @@ public final class MailManager
public final void deleteMessageInDb(int msgId) public final void deleteMessageInDb(int msgId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2Mentee; import com.l2jmobius.gameserver.model.L2Mentee;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -54,7 +54,7 @@ public class MentorManager
private void load() private void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees")) ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees"))
{ {
@@ -76,7 +76,7 @@ public class MentorManager
*/ */
public void deleteMentee(int mentorId, int menteeId) public void deleteMentee(int mentorId, int menteeId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
{ {
statement.setInt(1, mentorId); statement.setInt(1, mentorId);
@@ -95,7 +95,7 @@ public class MentorManager
*/ */
public void deleteMentor(int mentorId, int menteeId) public void deleteMentor(int mentorId, int menteeId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
{ {
statement.setInt(1, mentorId); statement.setInt(1, mentorId);
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.enums.ItemLocation; import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.idfactory.IdFactory; import com.l2jmobius.gameserver.idfactory.IdFactory;
@@ -145,7 +145,7 @@ public final class MercTicketManager
*/ */
private final void load() private final void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.util.Calendar; import java.util.Calendar;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -36,7 +36,7 @@ public class PremiumManager
public long getPremiumEndDate(String accountName) public long getPremiumEndDate(String accountName)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final PreparedStatement statement = con.prepareStatement("SELECT premium_service,enddate FROM account_premium WHERE account_name=?"); final PreparedStatement statement = con.prepareStatement("SELECT premium_service,enddate FROM account_premium WHERE account_name=?");
statement.setString(1, accountName); statement.setString(1, accountName);
@@ -70,7 +70,7 @@ public class PremiumManager
remainingTime -= System.currentTimeMillis(); remainingTime -= System.currentTimeMillis();
} }
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final Calendar endDate = Calendar.getInstance(); final Calendar endDate = Calendar.getInstance();
endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime); endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime);
@@ -100,7 +100,7 @@ public class PremiumManager
public void removePremiumStatus(String accountName) public void removePremiumStatus(String accountName)
{ {
// TODO: Add check if account exists. XD // TODO: Add check if account exists. XD
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final PreparedStatement statement = con.prepareStatement("INSERT INTO account_premium (account_name,premium_service,enddate) values(?,?,?) ON DUPLICATE KEY UPDATE premium_service = ?, enddate = ?"); final PreparedStatement statement = con.prepareStatement("INSERT INTO account_premium (account_name,premium_service,enddate) values(?,?,?) ON DUPLICATE KEY UPDATE premium_service = ?, enddate = ?");
statement.setString(1, accountName); statement.setString(1, accountName);
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.holders.PunishmentHolder; import com.l2jmobius.gameserver.model.holders.PunishmentHolder;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
@@ -56,7 +56,7 @@ public final class PunishmentManager
int expired = 0; int expired = 0;
// Load punishments. // Load punishments.
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement(); Statement st = con.createStatement();
ResultSet rset = st.executeQuery("SELECT * FROM punishments")) ResultSet rset = st.executeQuery("SELECT * FROM punishments"))
{ {
@@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.SpawnTable; import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.model.L2Spawn; import com.l2jmobius.gameserver.model.L2Spawn;
@@ -75,7 +75,7 @@ public class RaidBossSpawnManager
_storedInfo.clear(); _storedInfo.clear();
_schedules.clear(); _schedules.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM raidboss_spawnlist ORDER BY boss_id")) ResultSet rs = s.executeQuery("SELECT * FROM raidboss_spawnlist ORDER BY boss_id"))
{ {
@@ -264,7 +264,7 @@ public class RaidBossSpawnManager
if (storeInDb) if (storeInDb)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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(?,?,?,?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
{ {
ps.setInt(1, spawnDat.getId()); ps.setInt(1, spawnDat.getId());
@@ -325,7 +325,7 @@ public class RaidBossSpawnManager
if (updateDb) if (updateDb)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?"))
{ {
ps.setInt(1, bossId); ps.setInt(1, bossId);
@@ -344,7 +344,7 @@ public class RaidBossSpawnManager
*/ */
private void updateDb() private void updateDb()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?")) 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())
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2Spawn; import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Castle; import com.l2jmobius.gameserver.model.entity.Castle;
@@ -104,7 +104,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -124,7 +124,7 @@ public final class SiegeGuardManager
*/ */
public void removeMercs() public void removeMercs()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -191,7 +191,7 @@ public final class SiegeGuardManager
*/ */
private void loadSiegeGuard() private void loadSiegeGuard()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -237,7 +237,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)")) PreparedStatement ps = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)"))
{ {
ps.setInt(1, getCastle().getResidenceId()); ps.setInt(1, getCastle().getResidenceId());
@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@@ -87,7 +87,7 @@ public final class SiegeManager
} }
boolean register = false; boolean register = false;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?")) PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?"))
{ {
ps.setInt(1, clan.getId()); ps.setInt(1, clan.getId());
@@ -276,7 +276,7 @@ public final class SiegeManager
private final void loadTrapUpgrade(int castleId) private final void loadTrapUpgrade(int castleId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -91,7 +91,7 @@ public class Lottery
public void increasePrize(long count) public void increasePrize(long count)
{ {
_prize += count; _prize += count;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_PRICE)) PreparedStatement ps = con.prepareStatement(UPDATE_PRICE))
{ {
ps.setLong(1, getPrize()); ps.setLong(1, getPrize());
@@ -125,7 +125,7 @@ public class Lottery
@Override @Override
public void run() public void run()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery(SELECT_LAST_LOTTERY)) ResultSet rset = statement.executeQuery(SELECT_LAST_LOTTERY))
{ {
@@ -198,7 +198,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_LOTTERY)) PreparedStatement ps = con.prepareStatement(INSERT_LOTTERY))
{ {
ps.setInt(1, 1); ps.setInt(1, 1);
@@ -304,7 +304,7 @@ public class Lottery
int count3 = 0; int count3 = 0;
int count4 = 0; int count4 = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_ITEM)) PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_ITEM))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -419,7 +419,7 @@ public class Lottery
Broadcast.toAllOnlinePlayers(sm); Broadcast.toAllOnlinePlayers(sm);
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_LOTTERY)) PreparedStatement ps = con.prepareStatement(UPDATE_LOTTERY))
{ {
ps.setLong(1, getPrize()); ps.setLong(1, getPrize());
@@ -489,7 +489,7 @@ public class Lottery
0, 0,
0 0
}; };
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_TICKET)) PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_TICKET))
{ {
ps.setInt(1, id); ps.setInt(1, id);
@@ -31,7 +31,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.SpawnTable; import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.idfactory.IdFactory; import com.l2jmobius.gameserver.idfactory.IdFactory;
@@ -114,7 +114,7 @@ public class AutoSpawnHandler
private void restoreSpawnData() private void restoreSpawnData()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
@@ -26,7 +26,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable; import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -79,7 +79,7 @@ public class BlockList
public void updateBlockMemos() public void updateBlockMemos()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
for (int target : _updateMemos) for (int target : _updateMemos)
{ {
@@ -108,7 +108,7 @@ public class BlockList
private static HashMap<Integer, String> loadList(int ObjId) private static HashMap<Integer, String> loadList(int ObjId)
{ {
final HashMap<Integer, String> list = new HashMap<>(); final HashMap<Integer, String> list = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=1")) PreparedStatement ps = con.prepareStatement("SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=1"))
{ {
ps.setInt(1, ObjId); ps.setInt(1, ObjId);
@@ -136,7 +136,7 @@ public class BlockList
private void removeFromDB(int targetId) private void removeFromDB(int targetId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());
@@ -151,7 +151,7 @@ public class BlockList
private void persistInDB(int targetId) private void persistInDB(int targetId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)")) PreparedStatement ps = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());
@@ -24,7 +24,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.TransformData; import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.datatables.SkillData;
@@ -138,7 +138,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
{ {
@@ -483,7 +483,7 @@ public class CursedWeapon implements INamable
_log.info("CursedWeapon: Saving data to disk."); _log.info("CursedWeapon: Saving data to disk.");
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 (?, ?, ?, ?, ?, ?)"))
{ {
@@ -34,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.BB.Forum; import com.l2jmobius.gameserver.communitybbs.BB.Forum;
import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable; import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
@@ -246,7 +246,7 @@ public class L2Clan implements IIdentifiable, INamable
} }
else else
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -286,7 +286,7 @@ public class L2Clan implements IIdentifiable, INamable
} }
else else
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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));
@@ -881,7 +881,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateBloodAllianceCountInDB() public void updateBloodAllianceCountInDB()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -925,7 +925,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateBloodOathCountInDB() public void updateBloodOathCountInDB()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -943,7 +943,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateClanScoreInDB() public void updateClanScoreInDB()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -972,7 +972,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateClanInDB() public void updateClanInDB()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1014,7 +1014,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void store() public void store()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA)) PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -1050,7 +1050,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
private void removeMemberInDatabase(int playerId, long clanJoinExpiryTime, long clanCreateExpiryTime) private void removeMemberInDatabase(int playerId, long clanJoinExpiryTime, long clanCreateExpiryTime)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
@@ -1076,7 +1076,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restore() private void restore()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA)) PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -1156,7 +1156,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreNotice() private void restoreNotice()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1187,7 +1187,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1246,7 +1246,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreSkills() private void restoreSkills()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -1369,7 +1369,7 @@ public class L2Clan implements IIdentifiable, INamable
} }
} }
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
if (oldSkill != null) if (oldSkill != null)
{ {
@@ -1805,7 +1805,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreSubPledges() private void restoreSubPledges()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -1905,7 +1905,7 @@ public class L2Clan implements IIdentifiable, INamable
return null; return null;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1993,7 +1993,7 @@ public class L2Clan implements IIdentifiable, INamable
public void updateSubPledgeInDB(int pledgeType) public void updateSubPledgeInDB(int pledgeType)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -2014,7 +2014,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreRankPrivs() private void restoreRankPrivs()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -2067,7 +2067,7 @@ public class L2Clan implements IIdentifiable, INamable
{ {
_privs.get(rank).setPrivs(privs); _privs.get(rank).setPrivs(privs);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -2103,7 +2103,7 @@ public class L2Clan implements IIdentifiable, INamable
{ {
_privs.put(rank, new RankPrivs(rank, privs)); _privs.put(rank, new RankPrivs(rank, privs));
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -2241,7 +2241,7 @@ public class L2Clan implements IIdentifiable, INamable
if (storeInDb) if (storeInDb)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -2802,7 +2802,7 @@ public class L2Clan implements IIdentifiable, INamable
public void changeLevel(int level) public void changeLevel(int level)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -2848,7 +2848,7 @@ public class L2Clan implements IIdentifiable, INamable
setCrestId(crestId); setCrestId(crestId);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -2885,7 +2885,7 @@ public class L2Clan implements IIdentifiable, INamable
allyId = getAllyId(); allyId = getAllyId();
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sqlStatement)) PreparedStatement ps = con.prepareStatement(sqlStatement))
{ {
ps.setInt(1, crestId); ps.setInt(1, crestId);
@@ -2931,7 +2931,7 @@ public class L2Clan implements IIdentifiable, INamable
setCrestLargeId(crestId); setCrestLargeId(crestId);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -23,7 +23,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.instancemanager.SiegeManager; import com.l2jmobius.gameserver.instancemanager.SiegeManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -264,7 +264,7 @@ public class L2ClanMember
*/ */
public void updatePledgeType() public void updatePledgeType()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -313,7 +313,7 @@ public class L2ClanMember
*/ */
public void updatePowerGrade() public void updatePowerGrade()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -840,7 +840,7 @@ public class L2ClanMember
*/ */
public void saveApprenticeAndSponsor(int apprentice, int sponsor) public void saveApprenticeAndSponsor(int apprentice, int sponsor)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable; import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -57,7 +57,7 @@ public class L2ContactList
{ {
_contacts.clear(); _contacts.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_LOAD)) PreparedStatement ps = con.prepareStatement(QUERY_LOAD))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -123,7 +123,7 @@ public class L2ContactList
} }
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_ADD)) PreparedStatement ps = con.prepareStatement(QUERY_ADD))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -160,7 +160,7 @@ public class L2ContactList
_contacts.remove(name); _contacts.remove(name);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_REMOVE)) PreparedStatement ps = con.prepareStatement(QUERY_REMOVE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket; import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
@@ -49,7 +49,7 @@ public class L2Mentee
final L2PcInstance player = getPlayerInstance(); final L2PcInstance player = getPlayerInstance();
if (player == null) // Only if player is offline if (player == null) // Only if player is offline
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?")) PreparedStatement ps = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -29,7 +29,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.enums.MacroType; import com.l2jmobius.gameserver.enums.MacroType;
import com.l2jmobius.gameserver.enums.MacroUpdateType; import com.l2jmobius.gameserver.enums.MacroUpdateType;
import com.l2jmobius.gameserver.enums.ShortcutType; import com.l2jmobius.gameserver.enums.ShortcutType;
@@ -125,7 +125,7 @@ public class MacroList implements IRestorable
private void registerMacroInDb(Macro macro) private void registerMacroInDb(Macro macro)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -161,7 +161,7 @@ public class MacroList implements IRestorable
private void deleteMacroFromDb(Macro macro) private void deleteMacroFromDb(Macro macro)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -178,7 +178,7 @@ public class MacroList implements IRestorable
public boolean restoreMe() public boolean restoreMe()
{ {
_macroses.clear(); _macroses.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.enums.ShortcutType; import com.l2jmobius.gameserver.enums.ShortcutType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.IRestorable; import com.l2jmobius.gameserver.model.interfaces.IRestorable;
@@ -89,7 +89,7 @@ public class ShortCuts implements IRestorable
deleteShortCutFromDb(oldShortCut); deleteShortCutFromDb(oldShortCut);
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());
@@ -209,7 +209,7 @@ public class ShortCuts implements IRestorable
*/ */
private void deleteShortCutFromDb(Shortcut shortcut) private void deleteShortCutFromDb(Shortcut shortcut)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());
@@ -228,7 +228,7 @@ public class ShortCuts implements IRestorable
public boolean restoreMe() public boolean restoreMe()
{ {
_shortCuts.clear(); _shortCuts.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -25,7 +25,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.UIData; import com.l2jmobius.gameserver.data.xml.impl.UIData;
/** /**
@@ -104,7 +104,7 @@ public class UIKeysSettings
} }
} }
query = query.substring(0, query.length() - 1) + "; "; query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query)) PreparedStatement statement = con.prepareStatement(query))
{ {
statement.execute(); statement.execute();
@@ -125,7 +125,7 @@ public class UIKeysSettings
} }
query = query.substring(0, query.length() - 1) + ";"; query = query.substring(0, query.length() - 1) + ";";
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query)) PreparedStatement statement = con.prepareStatement(query))
{ {
statement.execute(); statement.execute();
@@ -146,7 +146,7 @@ public class UIKeysSettings
_storedCategories = new HashMap<>(); _storedCategories = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`")) PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{ {
ps.setInt(1, _playerObjId); ps.setInt(1, _playerObjId);
@@ -178,7 +178,7 @@ public class UIKeysSettings
_storedKeys = new HashMap<>(); _storedKeys = new HashMap<>();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`")) PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{ {
ps.setInt(1, _playerObjId); ps.setInt(1, _playerObjId);
@@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.GeoData; import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.ItemsAutoDestroy; import com.l2jmobius.gameserver.ItemsAutoDestroy;
@@ -1397,7 +1397,7 @@ public final class L2PcInstance extends L2Playable
private void insertNewRecipeData(int recipeId, boolean isDwarf) private void insertNewRecipeData(int recipeId, boolean isDwarf)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -1414,7 +1414,7 @@ public final class L2PcInstance extends L2Playable
private void deleteRecipeData(int recipeId, boolean isDwarf) private void deleteRecipeData(int recipeId, boolean isDwarf)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -7052,7 +7052,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public void updateOnlineStatus() public void updateOnlineStatus()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?")) PreparedStatement ps = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?"))
{ {
ps.setInt(1, isOnlineInt()); ps.setInt(1, isOnlineInt());
@@ -7072,7 +7072,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private boolean createDb() private boolean createDb()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CHARACTER)) PreparedStatement ps = con.prepareStatement(INSERT_CHARACTER))
{ {
ps.setString(1, _accountName); ps.setString(1, _accountName);
@@ -7136,7 +7136,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER)) 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
@@ -7470,7 +7470,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private static boolean restoreSubClassData(L2PcInstance player) private static boolean restoreSubClassData(L2PcInstance player)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_SUBCLASSES)) PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
{ {
ps.setInt(1, player.getObjectId()); ps.setInt(1, player.getObjectId());
@@ -7553,7 +7553,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sql)) PreparedStatement ps = con.prepareStatement(sql))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -7606,7 +7606,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sql)) PreparedStatement ps = con.prepareStatement(sql))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -7630,7 +7630,7 @@ public final class L2PcInstance extends L2Playable
public void updatePremiumItem(int itemNum, long newcount) public void updatePremiumItem(int itemNum, long newcount)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? ")) PreparedStatement ps = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? "))
{ {
ps.setLong(1, newcount); ps.setLong(1, newcount);
@@ -7646,7 +7646,7 @@ public final class L2PcInstance extends L2Playable
public void deletePremiumItem(int itemNum) public void deletePremiumItem(int itemNum)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? ")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? "))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -7705,7 +7705,7 @@ public final class L2PcInstance extends L2Playable
final long exp = getStat().getBaseExp(); final long exp = getStat().getBaseExp();
final int level = getStat().getBaseLevel(); final int level = getStat().getBaseLevel();
final long sp = getStat().getBaseSp(); final long sp = getStat().getBaseSp();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER)) PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))
{ {
ps.setInt(1, level); ps.setInt(1, level);
@@ -7793,7 +7793,7 @@ public final class L2PcInstance extends L2Playable
} }
// TODO(Zoey76): Refactor this to use batch. // TODO(Zoey76): Refactor this to use batch.
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_CHAR_SUBCLASS)) PreparedStatement ps = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
{ {
for (SubClass subClass : getSubClasses().values()) for (SubClass subClass : getSubClasses().values())
@@ -7824,7 +7824,7 @@ public final class L2PcInstance extends L2Playable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);)
{ {
@@ -7927,7 +7927,7 @@ public final class L2PcInstance extends L2Playable
private void storeItemReuseDelay() private void storeItemReuseDelay()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -8042,7 +8042,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_FROM_CHAR)) 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
@@ -8085,7 +8085,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 = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
if ((oldSkill != null) && (newSkill != null)) if ((oldSkill != null) && (newSkill != null))
{ {
@@ -8133,7 +8133,7 @@ public final class L2PcInstance extends L2Playable
} }
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex; final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS)) PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS))
{ {
con.setAutoCommit(false); con.setAutoCommit(false);
@@ -8159,7 +8159,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void restoreSkills() private void restoreSkills()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR)) 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
@@ -8210,7 +8210,7 @@ public final class L2PcInstance extends L2Playable
@Override @Override
public void restoreEffects() public void restoreEffects()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE)) PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -8267,7 +8267,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void restoreItemReuse() private void restoreItemReuse()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE); PreparedStatement ps = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);) PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);)
{ {
@@ -8338,7 +8338,7 @@ public final class L2PcInstance extends L2Playable
_henna[i] = null; _henna[i] = null;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_HENNAS)) PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_HENNAS))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -8426,7 +8426,7 @@ public final class L2PcInstance extends L2Playable
_henna[slot] = null; _henna[slot] = null;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_CHAR_HENNA)) PreparedStatement ps = con.prepareStatement(DELETE_CHAR_HENNA))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -8500,7 +8500,7 @@ public final class L2PcInstance extends L2Playable
} }
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_CHAR_HENNA)) PreparedStatement ps = con.prepareStatement(ADD_CHAR_HENNA))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -10534,7 +10534,7 @@ public final class L2PcInstance extends L2Playable
newClass.setLevel(Config.BASE_DUALCLASS_LEVEL); newClass.setLevel(Config.BASE_DUALCLASS_LEVEL);
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_CHAR_SUBCLASS)) 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.
@@ -10601,7 +10601,7 @@ public final class L2PcInstance extends L2Playable
try try
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -13298,7 +13298,7 @@ public final class L2PcInstance extends L2Playable
if ((_controlItemId != 0) && (petId != 0)) if ((_controlItemId != 0) && (petId != 0))
{ {
final String req = "UPDATE pets SET fed=? WHERE item_obj_id = ?"; final String req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(req)) PreparedStatement ps = con.prepareStatement(req))
{ {
ps.setInt(1, getCurrentFeed()); ps.setInt(1, getCurrentFeed());
@@ -13450,7 +13450,7 @@ public final class L2PcInstance extends L2Playable
bookmark.setTag(tag); bookmark.setTag(tag);
bookmark.setName(name); bookmark.setName(name);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_TP_BOOKMARK)) PreparedStatement ps = con.prepareStatement(UPDATE_TP_BOOKMARK))
{ {
ps.setInt(1, icon); ps.setInt(1, icon);
@@ -13473,7 +13473,7 @@ public final class L2PcInstance extends L2Playable
{ {
if (_tpbookmarks.remove(id) != null) if (_tpbookmarks.remove(id) != null)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_TP_BOOKMARK)) PreparedStatement ps = con.prepareStatement(DELETE_TP_BOOKMARK))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -13616,7 +13616,7 @@ public final class L2PcInstance extends L2Playable
sm.addItemName(20033); sm.addItemName(20033);
sendPacket(sm); sendPacket(sm);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_TP_BOOKMARK)) PreparedStatement ps = con.prepareStatement(INSERT_TP_BOOKMARK))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -13638,7 +13638,7 @@ public final class L2PcInstance extends L2Playable
public void restoreTeleportBookmark() public void restoreTeleportBookmark()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_TP_BOOKMARK)) PreparedStatement ps = con.prepareStatement(RESTORE_TP_BOOKMARK))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -13869,7 +13869,7 @@ public final class L2PcInstance extends L2Playable
public void updateMemos() public void updateMemos()
{ {
final String sqlQuery = "UPDATE character_friends SET memo=? WHERE charId=? AND friendId=? AND relation=0"; final String sqlQuery = "UPDATE character_friends SET memo=? WHERE charId=? AND friendId=? AND relation=0";
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
for (int target : _updateMemos) for (int target : _updateMemos)
{ {
@@ -13901,7 +13901,7 @@ public final class L2PcInstance extends L2Playable
_friendList.clear(); _friendList.clear();
final String sqlQuery = "SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=0"; final String sqlQuery = "SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=0";
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sqlQuery)) PreparedStatement ps = con.prepareStatement(sqlQuery))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -13949,7 +13949,7 @@ public final class L2PcInstance extends L2Playable
final Friend friend = _friendList.get(friendId); final Friend friend = _friendList.get(friendId);
int bClassId = 0; int bClassId = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE charId=?");) PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE charId=?");)
{ {
ps.setInt(1, friendId); ps.setInt(1, friendId);
@@ -13974,7 +13974,7 @@ public final class L2PcInstance extends L2Playable
} }
if (friend.getClassId() != bClassId) if (friend.getClassId() != bClassId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT level FROM character_subclasses WHERE charId=? AND class_id=?");) PreparedStatement ps = con.prepareStatement("SELECT level FROM character_subclasses WHERE charId=? AND class_id=?");)
{ {
ps.setInt(1, friendId); ps.setInt(1, friendId);
@@ -13997,7 +13997,7 @@ public final class L2PcInstance extends L2Playable
} }
if (friend.getClanId() != 0) if (friend.getClanId() != 0)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM clan_data WHERE clan_id=?");) PreparedStatement ps = con.prepareStatement("SELECT * FROM clan_data WHERE clan_id=?");)
{ {
ps.setInt(1, friend.getClanId()); ps.setInt(1, friend.getClanId());
@@ -14088,7 +14088,7 @@ public final class L2PcInstance extends L2Playable
{ {
if (hasManufactureShop()) if (hasManufactureShop())
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP)) try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
{ {
@@ -14126,7 +14126,7 @@ public final class L2PcInstance extends L2Playable
_manufactureItems.clear(); _manufactureItems.clear();
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP)) PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -14579,7 +14579,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void restorePetInventoryItems() private void restorePetInventoryItems()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;")) PreparedStatement ps = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -14619,7 +14619,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void loadRecommendations() private void loadRecommendations()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1")) PreparedStatement ps = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -14643,7 +14643,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public void storeRecommendations() public void storeRecommendations()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?)"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -14703,7 +14703,7 @@ public final class L2PcInstance extends L2Playable
private static void restorePremiumSystemData(L2PcInstance player, String account) private static void restorePremiumSystemData(L2PcInstance player, String account)
{ {
boolean success = false; boolean success = false;
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
final PreparedStatement ps = con.prepareStatement(RESTORE_PREMIUMSERVICE); final PreparedStatement ps = con.prepareStatement(RESTORE_PREMIUMSERVICE);
ps.setString(1, account); ps.setString(1, account);
@@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable; import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
@@ -793,7 +793,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
{ {
ps.setInt(1, getControlObjectId()); ps.setInt(1, getControlObjectId());
@@ -851,7 +851,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?")) 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;
@@ -952,7 +952,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(req)) PreparedStatement ps = con.prepareStatement(req))
{ {
ps.setString(1, getName()); ps.setString(1, getName());
@@ -1002,7 +1002,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -1069,7 +1069,7 @@ public class L2PetInstance extends L2Summon
@Override @Override
public void restoreEffects() public void restoreEffects()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable; import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
@@ -224,7 +224,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE)) 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
@@ -302,7 +302,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill())) if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
{ {
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -108,7 +108,7 @@ public class Announcement implements IAnnouncement
@Override @Override
public boolean storeMe() public boolean storeMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS)) PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{ {
ps.setInt(1, _type.ordinal()); ps.setInt(1, _type.ordinal());
@@ -134,7 +134,7 @@ public class Announcement implements IAnnouncement
@Override @Override
public boolean updateMe() public boolean updateMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY)) PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{ {
ps.setInt(1, _type.ordinal()); ps.setInt(1, _type.ordinal());
@@ -154,7 +154,7 @@ public class Announcement implements IAnnouncement
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_QUERY)) PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
{ {
ps.setInt(1, _id); ps.setInt(1, _id);
@@ -25,7 +25,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level; import java.util.logging.Level;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
@@ -94,7 +94,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override @Override
public boolean storeMe() public boolean storeMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS)) PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{ {
ps.setInt(1, getType().ordinal()); ps.setInt(1, getType().ordinal());
@@ -123,7 +123,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override @Override
public boolean updateMe() public boolean updateMe()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY)) PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{ {
ps.setInt(1, getType().ordinal()); ps.setInt(1, getType().ordinal());
@@ -24,7 +24,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.items.L2Item; import com.l2jmobius.gameserver.model.items.L2Item;
@@ -159,7 +159,7 @@ public final class Product
private void save() private void save()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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` = ?")) PreparedStatement ps = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?"))
{ {
ps.setInt(1, getBuyListId()); ps.setInt(1, getBuyListId());
@@ -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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.enums.AuctionItemType; import com.l2jmobius.gameserver.enums.AuctionItemType;
@@ -162,7 +162,7 @@ public class Auction
/** Load auctions */ /** Load auctions */
private void load() private void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?")) PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?"))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -197,7 +197,7 @@ public class Auction
_highestBidderName = ""; _highestBidderName = "";
_highestBidderMaxBid = 0; _highestBidderMaxBid = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC")) PreparedStatement ps = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -246,7 +246,7 @@ public class Auction
/** Save Auction Data End */ /** Save Auction Data End */
private void saveAuctionDate() private void saveAuctionDate()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("Update auction set endDate = ? where id = ?")) PreparedStatement ps = con.prepareStatement("Update auction set endDate = ? where id = ?"))
{ {
ps.setLong(1, _endDate); ps.setLong(1, _endDate);
@@ -344,7 +344,7 @@ public class Auction
*/ */
private void updateInDB(L2PcInstance bidder, long bid) private void updateInDB(L2PcInstance bidder, long bid)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
if (_bidders.get(bidder.getClanId()) != null) if (_bidders.get(bidder.getClanId()) != null)
{ {
@@ -401,7 +401,7 @@ public class Auction
/** Remove bids */ /** Remove bids */
private void removeBids() private void removeBids()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -434,7 +434,7 @@ public class Auction
public void deleteAuctionFromDB() public void deleteAuctionFromDB()
{ {
ClanHallAuctionManager.getInstance().getAuctions().remove(this); ClanHallAuctionManager.getInstance().getAuctions().remove(this);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction WHERE itemId=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
{ {
ps.setInt(1, _itemId); ps.setInt(1, _itemId);
@@ -490,7 +490,7 @@ public class Auction
*/ */
public synchronized void cancelBid(int bidder) public synchronized void cancelBid(int bidder)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
{ {
ps.setInt(1, getId()); ps.setInt(1, getId());
@@ -519,7 +519,7 @@ public class Auction
public void confirmAuction() public void confirmAuction()
{ {
ClanHallAuctionManager.getInstance().getAuctions().add(this); ClanHallAuctionManager.getInstance().getAuctions().add(this);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")) 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(1, getId());
@@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.xml.impl.CastleData; import com.l2jmobius.gameserver.data.xml.impl.CastleData;
@@ -219,7 +219,7 @@ public final class Castle extends AbstractResidence
public void dbSave() public void dbSave()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -360,7 +360,7 @@ public final class Castle extends AbstractResidence
} }
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -622,7 +622,7 @@ public final class Castle extends AbstractResidence
@Override @Override
protected void load() protected void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 = ?"))
{ {
@@ -669,7 +669,7 @@ public final class Castle extends AbstractResidence
/** Load All Functions */ /** Load All Functions */
private void loadFunctions() private void loadFunctions()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -694,7 +694,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -769,7 +769,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -795,7 +795,7 @@ public final class Castle extends AbstractResidence
door.setCurrentHp(door.getCurrentHp()); door.setCurrentHp(door.getCurrentHp());
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -820,7 +820,7 @@ public final class Castle extends AbstractResidence
if (save) if (save)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -847,7 +847,7 @@ public final class Castle extends AbstractResidence
CastleManorManager.getInstance().resetManorData(getResidenceId()); CastleManorManager.getInstance().resetManorData(getResidenceId());
} }
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.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 = ?"))
@@ -1026,7 +1026,7 @@ public final class Castle extends AbstractResidence
public void updateShowNpcCrest() public void updateShowNpcCrest()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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()));
@@ -1070,7 +1070,7 @@ public final class Castle extends AbstractResidence
{ {
_ticketBuyCount = count; _ticketBuyCount = count;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -1093,7 +1093,7 @@ public final class Castle extends AbstractResidence
{ {
if (save) if (save)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1120,7 +1120,7 @@ public final class Castle extends AbstractResidence
ts.setUpgradeLevel(0); ts.setUpgradeLevel(0);
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1210,7 +1210,7 @@ public final class Castle extends AbstractResidence
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
{ {
ps.setString(1, side.toString()); ps.setString(1, side.toString());
@@ -25,7 +25,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.L2Clan;
@@ -185,7 +185,7 @@ public abstract class ClanHall
public void dbSave() public void dbSave()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -443,7 +443,7 @@ public abstract class ClanHall
/** Load All Functions */ /** Load All Functions */
protected void loadFunctions() protected void loadFunctions()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -468,7 +468,7 @@ public abstract class ClanHall
public void removeFunction(int functionType) public void removeFunction(int functionType)
{ {
_functions.remove(functionType); _functions.remove(functionType);
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -23,7 +23,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.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.idfactory.IdFactory; import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -45,7 +45,7 @@ public class Couple
{ {
_Id = coupleId; _Id = coupleId;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -85,7 +85,7 @@ public class Couple
_weddingDate = Calendar.getInstance(); _weddingDate = Calendar.getInstance();
_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis()); _weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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();
@@ -105,7 +105,7 @@ public class Couple
public void marry() public void marry()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -123,7 +123,7 @@ public class Couple
public void divorce() public void divorce()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -34,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.FortUpdater; import com.l2jmobius.gameserver.FortUpdater;
import com.l2jmobius.gameserver.FortUpdater.UpdaterType; import com.l2jmobius.gameserver.FortUpdater.UpdaterType;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
@@ -219,7 +219,7 @@ public final class Fort extends AbstractResidence
public void dbSave() public void dbSave()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -492,7 +492,7 @@ public final class Fort extends AbstractResidence
public void saveFortVariables() public void saveFortVariables()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -559,7 +559,7 @@ public final class Fort extends AbstractResidence
@Override @Override
protected void load() protected void load()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -620,7 +620,7 @@ public final class Fort extends AbstractResidence
/** Load All Functions */ /** Load All Functions */
private void loadFunctions() private void loadFunctions()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -645,7 +645,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -747,7 +747,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -767,7 +767,7 @@ public final class Fort extends AbstractResidence
private void removeDoorUpgrade() private void removeDoorUpgrade()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -781,7 +781,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -810,7 +810,7 @@ public final class Fort extends AbstractResidence
_lastOwnedTime.setTimeInMillis(0); _lastOwnedTime.setTimeInMillis(0);
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -1022,7 +1022,7 @@ public final class Fort extends AbstractResidence
{ {
_state = state; _state = state;
_castleId = castleId; _castleId = castleId;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1154,7 +1154,7 @@ public final class Fort extends AbstractResidence
private void initNpcs() private void initNpcs()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1185,7 +1185,7 @@ public final class Fort extends AbstractResidence
private void initSiegeNpcs() private void initSiegeNpcs()
{ {
_siegeNpcs.clear(); _siegeNpcs.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1214,7 +1214,7 @@ public final class Fort extends AbstractResidence
private void initNpcCommanders() private void initNpcCommanders()
{ {
_npcCommanders.clear(); _npcCommanders.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1246,7 +1246,7 @@ public final class Fort extends AbstractResidence
_specialEnvoys.clear(); _specialEnvoys.clear();
_envoyCastles.clear(); _envoyCastles.clear();
_availableCastles.clear(); _availableCastles.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.enums.ChatType; import com.l2jmobius.gameserver.enums.ChatType;
@@ -493,7 +493,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -768,7 +768,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query)) PreparedStatement ps = con.prepareStatement(query))
{ {
ps.setInt(1, getFort().getResidenceId()); ps.setInt(1, getFort().getResidenceId());
@@ -982,7 +982,7 @@ public class FortSiege implements Siegable
private void loadSiegeClan() private void loadSiegeClan()
{ {
getAttackerClans().clear(); getAttackerClans().clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1043,7 +1043,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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1067,7 +1067,7 @@ public class FortSiege implements Siegable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
{ {
ps.setInt(1, clan.getId()); ps.setInt(1, clan.getId());
@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable; import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
@@ -108,7 +108,7 @@ public class Hero
HERO_DIARY.clear(); HERO_DIARY.clear();
HERO_MESSAGE.clear(); HERO_MESSAGE.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -206,7 +206,7 @@ public class Hero
*/ */
public void loadMessage(int charId) public void loadMessage(int charId)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT message FROM heroes WHERE charId=?")) PreparedStatement ps = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
{ {
ps.setInt(1, charId); ps.setInt(1, charId);
@@ -228,7 +228,7 @@ public class Hero
{ {
final List<StatsSet> diary = new ArrayList<>(); final List<StatsSet> diary = new ArrayList<>();
int diaryentries = 0; int diaryentries = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC")) PreparedStatement ps = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
{ {
ps.setInt(1, charId); ps.setInt(1, charId);
@@ -295,7 +295,7 @@ public class Hero
int _losses = 0; int _losses = 0;
int _draws = 0; int _draws = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC")) PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
{ {
ps.setInt(1, charId); ps.setInt(1, charId);
@@ -692,7 +692,7 @@ public class Hero
public void updateHeroes(boolean setDefault) public void updateHeroes(boolean setDefault)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
if (setDefault) if (setDefault)
{ {
@@ -823,7 +823,7 @@ public class Hero
public void setDiaryData(int charId, int action, int param) public void setDiaryData(int charId, int action, int param)
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
{ {
ps.setInt(1, charId); ps.setInt(1, charId);
@@ -859,7 +859,7 @@ public class Hero
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;")) PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{ {
ps.setString(1, HERO_MESSAGE.get(charId)); ps.setString(1, HERO_MESSAGE.get(charId));
@@ -874,7 +874,7 @@ public class Hero
private void deleteItemsInDb() private void deleteItemsInDb()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
s.executeUpdate(DELETE_ITEMS); s.executeUpdate(DELETE_ITEMS);
@@ -31,7 +31,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.xml.impl.SiegeScheduleData; import com.l2jmobius.gameserver.data.xml.impl.SiegeScheduleData;
@@ -771,7 +771,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
{ {
ps.setInt(1, getCastle().getResidenceId()); ps.setInt(1, getCastle().getResidenceId());
@@ -799,7 +799,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2")) PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
{ {
ps.setInt(1, getCastle().getResidenceId()); ps.setInt(1, getCastle().getResidenceId());
@@ -1026,7 +1026,7 @@ public class Siege implements Siegable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
{ {
ps.setInt(1, getCastle().getResidenceId()); ps.setInt(1, getCastle().getResidenceId());
@@ -1291,7 +1291,7 @@ public class Siege implements Siegable
/** Load siege clans. */ /** Load siege clans. */
private void loadSiegeClan() private void loadSiegeClan()
{ {
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?")) PreparedStatement ps = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
{ {
getAttackerClans().clear(); getAttackerClans().clear();
@@ -1402,7 +1402,7 @@ 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 = ConnectionFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
{ {
ps.setLong(1, getSiegeDate().getTimeInMillis()); ps.setLong(1, getSiegeDate().getTimeInMillis());
@@ -1431,7 +1431,7 @@ public class Siege implements Siegable
return; return;
} }
try (Connection con = ConnectionFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getInstance().getConnection())
{ {
if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER)) if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
{ {

Some files were not shown because too many files have changed in this diff Show More