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

View File

@ -256,12 +256,6 @@ ListOfProtectedItems = 0
# Default: 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.
# 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).

View File

@ -42,27 +42,32 @@ GameserverPort = 7777
# 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 = l2jgs/user = sa/password =
# 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 =
# Database Connection Pool
# Default: C3P0
# Available: C3P0, HikariCP, BoneCP
ConnectionPool = C3P0
# Default: 500
MaximumDbConnections = 500
# 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
# ---------------------------------------------------------------------------
# Misc Server Settings
# ---------------------------------------------------------------------------
@ -133,4 +138,4 @@ ClanNameTemplate = .*
# Maximum number of characters per account.
# Default: 7 (client limit)
CharMaxNumber = 7
CharMaxNumber = 7

View File

@ -30,7 +30,7 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture;
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.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
@ -844,7 +844,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
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 = ?"))
{
ps.setInt(1, clanId);
@ -858,7 +858,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
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 (?,?)"))
{
ps.setInt(1, clanId);
@ -874,7 +874,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
@Override
public void loadAttackers()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rset = s.executeQuery("SELECT * FROM rainbowsprings_attacker_list"))
{

View File

@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map;
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.ai.CtrlIntention;
import com.l2jmobius.gameserver.ai.L2SpecialSiegeGuardAI;
@ -760,7 +760,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
@Override
public final void loadAttackers()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{
ps.setInt(1, _hall.getId());
@ -800,7 +800,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_MEMEBERS))
{
ps.setInt(1, clanId);
@ -820,7 +820,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
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))
{
ps.setInt(1, _hall.getId());
@ -837,7 +837,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
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))
{
ps.setInt(1, npc);
@ -852,7 +852,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
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))
{
ps.setInt(1, _hall.getId());
@ -868,7 +868,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
private void clearTables()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(SQL_CLEAR_CLAN);
PreparedStatement ps2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS))
{

View File

@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
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.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2AccessLevel;
@ -73,7 +73,7 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
}
else
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
{
ps.setInt(1, lvl);

View File

@ -28,7 +28,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger;
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.xml.impl.ClassListData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
@ -576,7 +576,7 @@ public class AdminEditChar implements IAdminCommandHandler
if (player == null)
{
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))
{
ps.setString(1, playerName);

View File

@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.util.logging.Level;
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.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -63,7 +63,7 @@ public class AdminRepairChar implements IAdminCommandHandler
final String playerName = parts[1];
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))
{

View File

@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
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.instancemanager.QuestManager;
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)
{
// 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;
PreparedStatement req;

View File

@ -24,7 +24,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger;
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.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@ -525,7 +525,7 @@ public class AdminTeleport implements IAdminCommandHandler
final int x = activeChar.getX();
final int y = activeChar.getY();
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=?"))
{
ps.setInt(1, x);

View File

@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
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.handler.CommunityBoardHandler;
import com.l2jmobius.gameserver.handler.IParseBoardHandler;
@ -61,7 +61,7 @@ public class FavoriteBoard implements IParseBoardHandler
// Load Favorite links
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html");
final StringBuilder sb = new StringBuilder();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
{
ps.setInt(1, activeChar.getObjectId());
@ -98,7 +98,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
{
ps.setInt(1, activeChar.getObjectId());
@ -123,7 +123,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
{
ps.setInt(1, activeChar.getObjectId());

View File

@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
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.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
@ -176,7 +176,7 @@ public final class HomeBoard implements IParseBoardHandler
private static int getFavoriteCount(L2PcInstance player)
{
int count = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
{
ps.setInt(1, player.getObjectId());

View File

@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.util.logging.Level;
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.model.L2Clan;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -82,7 +82,7 @@ public class ClanWarsList implements IUserCommandHandler
query = WAR_LIST;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
ps.setInt(1, clan.getId());

View File

@ -23,7 +23,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention;
@ -208,7 +208,7 @@ public class Wedding implements IVoicedCommandHandler
// Check if target has player on friend list
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=?"))
{
statement.setInt(1, ptarget.getObjectId());

View File

@ -7,6 +7,7 @@
# 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).
# x.x.x.x - Format of an IP address. Do not include the x'es into settings. Must be real numbers.
# ---------------------------------------------------------------------------
# Networking
# ---------------------------------------------------------------------------
@ -30,6 +31,43 @@ LoginHostname = 127.0.0.1
# Default: 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
# ---------------------------------------------------------------------------
@ -62,44 +100,9 @@ FastConnectionTime = 350
# Default: 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.
@ -113,20 +116,22 @@ AutoCreateAccounts = True
# Defaults to the directory where the server data are stored.
DatapackRoot = data\
# ---------------------------------------------------------------------------
# Scheduled Login Restart
# ---------------------------------------------------------------------------
# Enable disable scheduled login restart.
# Default: False
LoginRestartSchedule = False
# Time in hours.
# Default: 24
LoginRestartTime = 24
# ---------------------------------------------------------------------------
# Developer Settings
# ---------------------------------------------------------------------------
# Default: False
Debug = False
# ---------------------------------------------------------------------------
# Restart LS every 24 hours?
# ---------------------------------------------------------------------------
# Enable disable scheduled login restart.
# Default: False
LoginRestartSchedule = True
# Time in hours.
# Default: 24
LoginRestartTime = 24

View File

@ -482,7 +482,6 @@ public final class Config
public static int HERB_AUTO_DESTROY_TIME;
public static List<Integer> LIST_PROTECTED_ITEMS;
public static boolean DATABASE_CLEAN_UP;
public static long CONNECTION_CLOSE_TIME;
public static int CHAR_STORE_INTERVAL;
public static boolean LAZY_ITEMS_UPDATE;
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_LOGIN;
public static String DATABASE_PASSWORD;
public static String DATABASE_CONNECTION_POOL;
public static int DATABASE_MAX_CONNECTIONS;
public static int DATABASE_MAX_IDLE_TIME;
public static long CONNECTION_CLOSE_TIME;
public static int MAXIMUM_ONLINE_USERS;
public static Pattern CHARNAME_TEMPLATE_PATTERN;
public static String PET_NAME_TEMPLATE;
@ -1182,12 +1181,12 @@ public final class Config
ACCEPT_ALTERNATE_ID = serverSettings.getBoolean("AcceptAlternateID", true);
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_PASSWORD = serverSettings.getString("Password", "");
DATABASE_CONNECTION_POOL = serverSettings.getString("ConnectionPool", "C3P0");
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 500);
DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0);
CONNECTION_CLOSE_TIME = serverSettings.getLong("ConnectionCloseTime", 60000);
Pattern charNamePattern;
@ -1833,7 +1832,6 @@ public final class Config
LIST_PROTECTED_ITEMS.add(Integer.parseInt(id));
}
DATABASE_CLEAN_UP = General.getBoolean("DatabaseCleanUp", true);
CONNECTION_CLOSE_TIME = General.getLong("ConnectionCloseTime", 60000);
CHAR_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15);
LAZY_ITEMS_UPDATE = General.getBoolean("LazyItemsUpdate", 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);
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_PASSWORD = ServerSettings.getString("Password", "");
DATABASE_CONNECTION_POOL = ServerSettings.getString("ConnectionPool", "C3P0");
DATABASE_MAX_CONNECTIONS = ServerSettings.getInt("MaximumDbConnections", 10);
DATABASE_MAX_IDLE_TIME = ServerSettings.getInt("MaximumDbIdleTime", 0);
CONNECTION_CLOSE_TIME = ServerSettings.getLong("ConnectionCloseTime", 60000);

View File

@ -14,37 +14,32 @@
* 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;
package com.l2jmobius.commons.database;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Logger;
import javax.sql.DataSource;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.AbstractConnectionFactory;
import com.l2jmobius.commons.database.pool.IConnectionFactory;
import com.mchange.v2.c3p0.ComboPooledDataSource;
/**
* C3P0 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>
* Database Factory implementation.
* @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;
public C3P0ConnectionFactory()
public DatabaseFactory()
{
if (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();
@ -57,10 +52,8 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
_dataSource.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
_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.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time
// cause there is a "long" delay on acquire connection
// so taking more than one connection at once will make connection pooling
// more effective.
_dataSource.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time cause there is
// a "long" delay on acquire connection so taking more than one connection at once will make connection pooling more effective.
// this "connection_test_table" is automatically created if not already there
_dataSource.setAutomaticTestTable("connection_test_table");
@ -70,19 +63,14 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
_dataSource.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
_dataSource.setMaxIdleTime(Config.DATABASE_MAX_IDLE_TIME); // 0 = idle connections never expire
// *THANKS* to connection testing configured above
// but I prefer to disconnect all connections not used
// for more than 1 hour
// *THANKS* to connection testing configured above but I prefer to disconnect all connections not used for more than 1 hour
// enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
_dataSource.setMaxStatementsPerConnection(100);
_dataSource.setBreakAfterAcquireFailure(false); // never fail if any way possible
// setting this to true will make
// c3p0 "crash" and refuse to work
// till restart thus making acquire
// errors "FATAL" ... we don't want that
// it should be possible to recover
_dataSource.setBreakAfterAcquireFailure(false); // never fail if any way possible setting this to true will make c3p0 "crash"
// and refuse to work till restart thus making acquire errors "FATAL" ... we don't want that it should be possible to recover
try
{
_dataSource.setDriverClass(Config.DATABASE_DRIVER);
@ -104,14 +92,25 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
{
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()
{
try
@ -120,23 +119,17 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
}
catch (Exception e)
{
LOG.info(e.getMessage());
_log.info(e.getMessage());
}
}
@Override
public DataSource getDataSource()
{
return _dataSource;
}
public static IConnectionFactory getInstance()
public static DatabaseFactory getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final IConnectionFactory INSTANCE = new C3P0ConnectionFactory();
protected static final DatabaseFactory INSTANCE = new DatabaseFactory();
}
}

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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();
}
}

View File

@ -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;
}
}
}
}
}

View File

@ -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();
}
}

View File

@ -30,7 +30,7 @@ import java.util.logging.Logger;
import com.l2jmobius.Config;
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.SelectorThread;
import com.l2jmobius.gameserver.cache.HtmCache;
@ -480,7 +480,7 @@ public final class GameServer
// Initialize config
Config.load();
printSection("Database");
ConnectionFactory.getInstance();
DatabaseFactory.getInstance();
gameServer = new GameServer();
if (Config.IS_TELNET_ENABLED)

View File

@ -43,7 +43,7 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
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.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
@ -580,7 +580,7 @@ public class LoginServerThread extends Thread
{
int chars = 0;
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=?"))
{
ps.setString(1, account);

View File

@ -20,7 +20,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.OfflineTradersTable;
import com.l2jmobius.gameserver.datatables.BotReportTable;
@ -263,8 +263,8 @@ public class Shutdown extends Thread
// commit data, last chance
try
{
ConnectionFactory.getInstance().close();
_log.info("L2Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
DatabaseFactory.getInstance().close();
_log.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
}
catch (Throwable t)
{

View File

@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.TopicBBSManager;
@ -91,7 +91,7 @@ public final class Forum
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=?"))
{
ps.setInt(1, _forumId);
@ -112,7 +112,7 @@ public final class Forum
_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"))
{
ps.setInt(1, _forumId);
@ -137,7 +137,7 @@ public final class Forum
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=?"))
{
ps.setInt(1, _forumId);
@ -215,7 +215,7 @@ public final class Forum
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 (?,?,?,?,?,?,?)"))
{
ps.setInt(1, _forumId);

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.logging.Level;
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;
/**
@ -76,7 +76,7 @@ public class Post
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 (?,?,?,?,?,?,?)"))
{
ps.setInt(1, cp.postId);
@ -102,7 +102,7 @@ public class Post
public void deleteme(Topic 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=?"))
{
ps.setInt(1, t.getForumID());
@ -120,7 +120,7 @@ public class Post
*/
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"))
{
ps.setInt(1, t.getForumID());
@ -153,7 +153,7 @@ public class Post
public void updatetxt(int 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=?"))
{
ps.setString(1, cp.postTxt);

View File

@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
import java.util.logging.Level;
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;
public class Topic
@ -71,7 +71,7 @@ public class Topic
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 (?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, _id);
@ -129,7 +129,7 @@ public class Topic
{
TopicBBSManager.getInstance().delTopic(this);
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=?"))
{
ps.setInt(1, getID());

View File

@ -24,7 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
@ -39,7 +39,7 @@ public class ForumsBBSManager extends BaseBBSManager
*/
protected ForumsBBSManager()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT forum_id FROM forums WHERE forum_type = 0"))
{

View File

@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.Announcement;
@ -52,7 +52,7 @@ public final class AnnouncementsTable
private void load()
{
_announcements.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
{

View File

@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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;
/**
@ -99,7 +99,7 @@ public class CharNameTable
int id = -1;
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=?"))
{
ps.setString(1, name);
@ -145,7 +145,7 @@ public class CharNameTable
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=?"))
{
ps.setInt(1, id);
@ -181,7 +181,7 @@ public class CharNameTable
public synchronized boolean doesCharNameExist(String name)
{
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=?"))
{
ps.setString(1, name);
@ -199,7 +199,7 @@ public class CharNameTable
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=?"))
{
ps.setString(1, account);
@ -220,7 +220,7 @@ public class CharNameTable
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 = ?"))
{
ps.setInt(1, objectId);
@ -241,7 +241,7 @@ public class CharNameTable
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 = ?"))
{
ps.setInt(1, objectId);
@ -262,7 +262,7 @@ public class CharNameTable
private void loadAll()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT charId, char_name, accesslevel FROM characters"))
{

View File

@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
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.PetDataTable;
import com.l2jmobius.gameserver.datatables.SkillData;
@ -70,7 +70,7 @@ public class CharSummonTable
{
if (Config.RESTORE_SERVITOR_ON_RECONNECT)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_SUMMONS))
{
@ -87,7 +87,7 @@ public class CharSummonTable
if (Config.RESTORE_PET_ON_RECONNECT)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_PET))
{
@ -111,7 +111,7 @@ public class CharSummonTable
return !v.isEmpty() ? v : null;
});
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
{
ps.setInt(1, activeChar.getObjectId());
@ -181,7 +181,7 @@ public class CharSummonTable
public void restoreServitor(L2PcInstance activeChar)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
{
ps.setInt(1, activeChar.getObjectId());
@ -227,7 +227,7 @@ public class CharSummonTable
_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))
{
ps.setInt(1, summon.getOwner().getObjectId());

View File

@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.communitybbs.Manager.ForumsBBSManager;
import com.l2jmobius.gameserver.enums.UserInfoType;
@ -80,7 +80,7 @@ public class ClanTable
L2Clan clan;
// Count the clans
int clanCount = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{
@ -273,7 +273,7 @@ public class ClanTable
_clans.remove(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=?"))
{
@ -390,7 +390,7 @@ public class ClanTable
clan2.setAttackerClan(clan1);
clan1.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(?,?,?,?)"))
{
ps.setInt(1, clanId1);
@ -432,7 +432,7 @@ public class ClanTable
clan1.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=?"))
{
ps.setInt(1, clanId1);
@ -474,7 +474,7 @@ public class ClanTable
private void restorewars()
{
L2Clan clan1, clan2;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT clan1, clan2 FROM clan_wars"))
{

View File

@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
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.L2Crest;
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);
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)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
{
final L2Crest crest = new L2Crest(getNextId(), data, crestType);
@ -196,7 +196,7 @@ public final class CrestTable
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM `crests` WHERE `crest_id` = ?"))
{
statement.setInt(1, crestId);

View File

@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.SkillHolder;
@ -88,7 +88,7 @@ public class NpcBufferTable
protected NpcBufferTable()
{
int skillCount = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
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"))
{
@ -135,7 +135,7 @@ public class NpcBufferTable
if (Config.CUSTOM_NPCBUFFER_TABLES)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
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"))
{

View File

@ -25,7 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.L2ManufactureItem;
@ -51,7 +51,7 @@ public class OfflineTradersTable
public void storeOffliners()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE);
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS);
PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS);
@ -153,7 +153,7 @@ public class OfflineTradersTable
{
LOGGER.info(getClass().getSimpleName() + ": Loading offline traders...");
int nTraders = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement stm = con.createStatement();
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)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER);
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER);
PreparedStatement stm3 = con.prepareStatement(SAVE_ITEMS);

View File

@ -27,7 +27,7 @@ import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
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;
public class PetNameTable
@ -42,7 +42,7 @@ public class PetNameTable
public boolean doesPetNameExist(String name, int petNpcId)
{
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 (?)"))
{
ps.setString(1, name);

View File

@ -27,7 +27,7 @@ import java.util.Map;
import java.util.logging.Level;
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.model.actor.L2Summon;
@ -45,7 +45,7 @@ public class SummonSkillsTable
{
_skillTrees.clear();
int count = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT templateId, minLvl, skillId, skillLvl FROM pets_skills"))
{

View File

@ -25,7 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.model.L2TeleportLocation;
public class TeleportLocationTable
@ -42,7 +42,7 @@ public class TeleportLocationTable
public void reloadAll()
{
_teleports.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
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)
{
int _cTeleCount = _teleports.size();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM custom_teleport"))
{

View File

@ -25,7 +25,7 @@ import java.util.Map;
import java.util.logging.Level;
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.Location;
@ -72,7 +72,7 @@ public class TerritoryTable
public void load()
{
_territory.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery("SELECT * FROM locations WHERE loc_id>0"))
{

View File

@ -30,7 +30,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
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.model.buylist.L2BuyList;
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.");
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`"))
{

View File

@ -36,7 +36,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
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.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object;
@ -109,7 +109,7 @@ public final class BotReportTable
*/
private void loadReportedCharData()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery(SQL_LOAD_REPORTED_CHAR_DATA))
{
@ -178,7 +178,7 @@ public final class BotReportTable
*/
public void saveReportedCharData()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement();
PreparedStatement ps = con.prepareStatement(SQL_INSERT_REPORTED_CHAR_DATA))
{

View File

@ -30,7 +30,7 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
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.data.xml.impl.EnchantItemHPBonusData;
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 (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=?"))
{
// Delete the pet in db

View File

@ -34,7 +34,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
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.instancemanager.DayNightSpawnManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
@ -255,7 +255,7 @@ public final class SpawnTable implements IXmlReader
private int fillSpawnTable(boolean isCustom)
{
int npcSpawnCount = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(isCustom ? SELECT_CUSTOM_SPAWNS : SELECT_SPAWNS))
{
@ -416,7 +416,7 @@ public final class SpawnTable implements IXmlReader
if (storeInDb)
{
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(?,?,?,?,?,?,?,?,?)"))
{
insert.setInt(1, spawn.getAmount());
@ -451,7 +451,7 @@ public final class SpawnTable implements IXmlReader
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=?"))
{
delete.setInt(1, spawn.getX());

View File

@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
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
@ -39,7 +39,7 @@ public class CompactionIDFactory extends IdFactory
_curOID = FIRST_OID;
_freeSize = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
final Integer[] tmp_obj_ids = extractUsedObjectIDTable();

View File

@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.commons.database.DatabaseFactory;
/**
* This class ...
@ -181,7 +181,7 @@ public abstract class IdFactory
*/
private void setAllCharacterOffline()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("UPDATE characters SET online = 0");
@ -198,7 +198,7 @@ public abstract class IdFactory
*/
private void cleanUpDB()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement stmt = con.createStatement())
{
final long cleanupStart = System.currentTimeMillis();
@ -310,7 +310,7 @@ public abstract class IdFactory
private void cleanInvalidWeddings()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
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()
{
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
int cleanCount = 0;
for (String line : TIMESTAMPS_CLEAN)
@ -351,7 +351,7 @@ public abstract class IdFactory
protected final Integer[] extractUsedObjectIDTable() throws Exception
{
final List<Integer> temp = new ArrayList<>();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
String extractUsedObjectIdsQuery = "";

View File

@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.util.Stack;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.commons.database.DatabaseFactory;
/**
* This class ...
@ -42,7 +42,7 @@ public class StackIDFactory extends IdFactory
_curOID = 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");

View File

@ -26,7 +26,7 @@ import java.util.Map;
import java.util.logging.Level;
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.StatsSet;
import com.l2jmobius.gameserver.model.VehiclePathPoint;
@ -169,7 +169,7 @@ public class AirShipManager
_airShipsInfo.put(ownerId, info);
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_DB))
{
ps.setInt(1, ownerId);
@ -265,7 +265,7 @@ public class AirShipManager
private void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(LOAD_DB))
{
@ -296,7 +296,7 @@ public class AirShipManager
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_DB))
{
ps.setInt(1, info.getInt("fuel"));

View File

@ -24,7 +24,7 @@ import java.util.Map;
import java.util.logging.Logger;
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.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
@ -52,7 +52,7 @@ public final class CHSiegeManager
private final void loadClanHalls()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(SQL_LOAD_HALLS))
{

View File

@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.model.L2Clan;
import com.l2jmobius.gameserver.model.L2ClanMember;
@ -250,7 +250,7 @@ public final class CastleManager implements InstanceListManager
}
}
// 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 = ?"))
{
ps.setInt(1, member.getObjectId());
@ -267,7 +267,7 @@ public final class CastleManager implements InstanceListManager
@Override
public void loadInstances()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id FROM castle ORDER BY id"))
{

View File

@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
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.enums.ManorMode;
import com.l2jmobius.gameserver.model.CropProcure;
@ -164,7 +164,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
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 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);
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 ips = con.prepareStatement(INSERT_PRODUCT))
{
@ -478,7 +478,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
_procureNext.put(castleId, list);
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 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)
{
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"))
{
for (SeedProduction sp : items)
@ -532,7 +532,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
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"))
{
for (CropProcure sp : items)
@ -605,7 +605,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
@Override
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 is = con.prepareStatement(INSERT_PRODUCT);
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)
{
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 dc = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ?"))
{

View File

@ -33,7 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.model.clan.entry.PledgeApplicantInfo;
import com.l2jmobius.gameserver.model.clan.entry.PledgeRecruitInfo;
@ -91,7 +91,7 @@ public class ClanEntryManager
private final void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit"))
{
@ -106,7 +106,7 @@ public class ClanEntryManager
_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();
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());
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
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"))
{
@ -168,7 +168,7 @@ public class ClanEntryManager
{
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))
{
statement.setInt(1, playerId);
@ -189,7 +189,7 @@ public class ClanEntryManager
{
_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))
{
statement.setInt(1, info.getPlayerId());
@ -216,7 +216,7 @@ public class ClanEntryManager
{
if (!_playerLocked.containsKey(playerId))
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST))
{
statement.setInt(1, info.getPlayerId());
@ -237,7 +237,7 @@ public class ClanEntryManager
{
if (_waitingList.containsKey(playerId))
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST))
{
statement.setInt(1, playerId);
@ -258,7 +258,7 @@ public class ClanEntryManager
{
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))
{
statement.setInt(1, info.getClanId());
@ -280,7 +280,7 @@ public class ClanEntryManager
{
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))
{
statement.setInt(1, info.getKarma());
@ -302,7 +302,7 @@ public class ClanEntryManager
{
if (_clanList.containsKey(clanId))
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_CLAN_RECRUIT))
{
statement.setInt(1, clanId);

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.logging.Level;
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;
/**
@ -98,7 +98,7 @@ public final class ClanHallAuctionManager
private final void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id FROM auction ORDER BY id"))
{
@ -163,7 +163,7 @@ public final class ClanHallAuctionManager
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("INSERT INTO `auction` VALUES " + ITEM_INIT_DATA[i]);

View File

@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object;
@ -62,7 +62,7 @@ public final class ClanHallManager
/** Load All Clan Hall */
private final void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM clanhall ORDER BY id"))
{

View File

@ -34,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.enums.ItemLocation;
import com.l2jmobius.gameserver.enums.MailType;
@ -79,7 +79,7 @@ public final class CommissionManager
protected CommissionManager()
{
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))
{
@ -253,7 +253,7 @@ public final class CommissionManager
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS))
{
final Instant startTime = Instant.now();
@ -406,7 +406,7 @@ public final class CommissionManager
*/
private boolean deleteItemFromDB(long commissionId)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM))
{
ps.setLong(1, commissionId);

View File

@ -24,7 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
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.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Couple;
@ -51,7 +51,7 @@ public final class CoupleManager
private final void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement ps = con.createStatement();
ResultSet rs = ps.executeQuery("SELECT id FROM mods_wedding ORDER BY id"))
{

View File

@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
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.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
@ -170,7 +170,7 @@ public final class CursedWeaponsManager
private final void restore()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
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...
// 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=?"))
{
for (CursedWeapon cw : _cursedWeapons.values())
@ -369,7 +369,7 @@ public final class CursedWeaponsManager
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 = ?"))
{
ps.setInt(1, itemId);

View File

@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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;
/**
@ -46,7 +46,7 @@ public class FactionManager
private void loadAll()
{
_playerFactions.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
{
@ -76,7 +76,7 @@ public class FactionManager
return factionId;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
{
ps.setInt(1, id);

View File

@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.datatables.ItemTable;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
@ -99,7 +99,7 @@ public class FishingChampionshipManager
{
_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 ResultSet rs = statement.executeQuery();
@ -379,7 +379,7 @@ public class FishingChampionshipManager
{
GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate);
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE);
statement.execute();

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.logging.Level;
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.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object;
@ -160,7 +160,7 @@ public final class FortManager implements InstanceListManager
@Override
public void loadInstances()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id FROM fort ORDER BY id"))
{

View File

@ -26,7 +26,7 @@ import java.util.Map;
import java.util.logging.Level;
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.entity.Fort;
@ -104,7 +104,7 @@ public final class FortSiegeGuardManager
void loadSiegeGuard()
{
_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 = ?"))
{
final int fortId = getFort().getResidenceId();

View File

@ -32,7 +32,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.FortSiegeSpawn;
import com.l2jmobius.gameserver.model.L2Clan;
@ -86,7 +86,7 @@ public final class FortSiegeManager
}
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=?"))
{
ps.setInt(1, clan.getId());

View File

@ -33,7 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.datatables.SpawnTable;
@ -417,7 +417,7 @@ public final class FourSepulchersManager
{
_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"))
{
ps.setInt(1, 0);
@ -474,7 +474,7 @@ public final class FourSepulchersManager
_physicalMonsters.clear();
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"))
{
ps1.setInt(1, 1);
@ -521,7 +521,7 @@ public final class FourSepulchersManager
_magicalMonsters.clear();
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"))
{
ps1.setInt(1, 2);
@ -570,7 +570,7 @@ public final class FourSepulchersManager
_archonSpawned.clear();
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"))
{
ps1.setInt(1, 5);
@ -621,7 +621,7 @@ public final class FourSepulchersManager
_emperorsGraveNpcs.clear();
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"))
{
ps1.setInt(1, 6);

View File

@ -25,7 +25,7 @@ import java.util.Map.Entry;
import java.util.logging.Level;
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;
/**
@ -50,7 +50,7 @@ public final class GlobalVariablesManager extends AbstractVariables
public boolean restoreMe()
{
// Restore previous variables.
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery(SELECT_QUERY))
{
@ -81,7 +81,7 @@ public final class GlobalVariablesManager extends AbstractVariables
return false;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement del = con.createStatement();
PreparedStatement st = con.prepareStatement(INSERT_QUERY))
{
@ -113,7 +113,7 @@ public final class GlobalVariablesManager extends AbstractVariables
@Override
public boolean deleteMe()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement del = con.createStatement())
{
del.execute(DELETE_QUERY);

View File

@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.instancemanager.tasks.GrandBossManagerStoreTask;
@ -73,7 +73,7 @@ public final class GrandBossManager implements IStorable
private void init()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
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<>());
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_list ORDER BY player_id"))
{
@ -235,7 +235,7 @@ public final class GrandBossManager implements IStorable
@Override
public boolean storeMe()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
s.executeUpdate(DELETE_GRAND_BOSS_LIST);
@ -308,7 +308,7 @@ public final class GrandBossManager implements IStorable
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 StatsSet info = _storedInfo.get(bossId);

View File

@ -28,7 +28,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
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.entity.Instance;
import com.l2jmobius.gameserver.model.instancezone.InstanceWorld;
@ -121,7 +121,7 @@ public final class InstanceManager implements IXmlReader
restoreInstanceTimes(playerObjId);
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_INSTANCE_TIME))
{
ps.setInt(1, playerObjId);
@ -143,7 +143,7 @@ public final class InstanceManager implements IXmlReader
*/
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))
{
ps.setInt(1, playerObjId);
@ -167,7 +167,7 @@ public final class InstanceManager implements IXmlReader
return; // already restored
}
_playerInstanceTimes.put(playerObjId, new ConcurrentHashMap<>());
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_INSTANCE_TIMES))
{
ps.setInt(1, playerObjId);

View File

@ -35,7 +35,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
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;
/**
@ -58,7 +58,7 @@ public final class ItemAuctionManager
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
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)
{
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?"))
{

View File

@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.ThreadPoolManager;
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";
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(str))
{
ps.setLong(1, System.currentTimeMillis());
@ -93,7 +93,7 @@ public final class ItemsOnGroundManager implements Runnable
}
// 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"))
{
int count = 0;
@ -179,7 +179,7 @@ public final class ItemsOnGroundManager implements Runnable
public void emptyTable()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("DELETE FROM itemsonground");
@ -205,7 +205,7 @@ public final class ItemsOnGroundManager implements Runnable
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(?,?,?,?,?,?,?,?,?)"))
{
for (L2ItemInstance item : _items)

View File

@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.tasks.MessageDeletionTask;
@ -56,7 +56,7 @@ public final class MailManager
private void load()
{
int count = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement ps = con.createStatement();
ResultSet rs = ps.executeQuery("SELECT * FROM messages ORDER BY expiration"))
{
@ -171,7 +171,7 @@ public final class MailManager
public void sendMessage(Message msg)
{
_messages.put(msg.getId(), msg);
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = Message.getStatement(msg, con))
{
ps.execute();
@ -193,7 +193,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@ -207,7 +207,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@ -221,7 +221,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@ -235,7 +235,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@ -249,7 +249,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);

View File

@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -54,7 +54,7 @@ public class MentorManager
private void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees"))
{
@ -76,7 +76,7 @@ public class MentorManager
*/
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 = ?"))
{
statement.setInt(1, mentorId);
@ -95,7 +95,7 @@ public class MentorManager
*/
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 = ?"))
{
statement.setInt(1, mentorId);

View File

@ -24,7 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
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.enums.ItemLocation;
import com.l2jmobius.gameserver.idfactory.IdFactory;
@ -145,7 +145,7 @@ public final class MercTicketManager
*/
private final void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1"))
{

View File

@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.util.Calendar;
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.actor.instance.L2PcInstance;
@ -36,7 +36,7 @@ public class PremiumManager
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=?");
statement.setString(1, accountName);
@ -70,7 +70,7 @@ public class PremiumManager
remainingTime -= System.currentTimeMillis();
}
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
final Calendar endDate = Calendar.getInstance();
endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime);
@ -100,7 +100,7 @@ public class PremiumManager
public void removePremiumStatus(String accountName)
{
// 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 = ?");
statement.setString(1, accountName);

View File

@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
@ -56,7 +56,7 @@ public final class PunishmentManager
int expired = 0;
// Load punishments.
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery("SELECT * FROM punishments"))
{

View File

@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.datatables.SpawnTable;
import com.l2jmobius.gameserver.model.L2Spawn;
@ -75,7 +75,7 @@ public class RaidBossSpawnManager
_storedInfo.clear();
_schedules.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM raidboss_spawnlist ORDER BY boss_id"))
{
@ -264,7 +264,7 @@ public class RaidBossSpawnManager
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(?,?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, spawnDat.getId());
@ -325,7 +325,7 @@ public class RaidBossSpawnManager
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=?"))
{
ps.setInt(1, bossId);
@ -344,7 +344,7 @@ public class RaidBossSpawnManager
*/
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 = ?"))
{
for (Integer bossId : _storedInfo.keySet())

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.logging.Level;
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.actor.instance.L2PcInstance;
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)
{
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"))
{
ps.setInt(1, npcId);
@ -124,7 +124,7 @@ public final class SiegeGuardManager
*/
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"))
{
ps.setInt(1, getCastle().getResidenceId());
@ -191,7 +191,7 @@ public final class SiegeGuardManager
*/
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 = ?"))
{
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)
{
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 (?, ?, ?, ?, ?, ?, ?, ?)"))
{
ps.setInt(1, getCastle().getResidenceId());

View File

@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.model.L2Clan;
import com.l2jmobius.gameserver.model.L2Object;
@ -87,7 +87,7 @@ public final class SiegeManager
}
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=?"))
{
ps.setInt(1, clan.getId());
@ -276,7 +276,7 @@ public final class SiegeManager
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=?"))
{
ps.setInt(1, castleId);

View File

@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
@ -91,7 +91,7 @@ public class Lottery
public void increasePrize(long count)
{
_prize += count;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_PRICE))
{
ps.setLong(1, getPrize());
@ -125,7 +125,7 @@ public class Lottery
@Override
public void run()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement statement = con.createStatement();
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 finishLottery(), _enddate - System.currentTimeMillis());
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_LOTTERY))
{
ps.setInt(1, 1);
@ -304,7 +304,7 @@ public class Lottery
int count3 = 0;
int count4 = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_ITEM))
{
ps.setInt(1, getId());
@ -419,7 +419,7 @@ public class Lottery
Broadcast.toAllOnlinePlayers(sm);
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_LOTTERY))
{
ps.setLong(1, getPrize());
@ -489,7 +489,7 @@ public class Lottery
0,
0
};
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_TICKET))
{
ps.setInt(1, id);

View File

@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
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.datatables.SpawnTable;
import com.l2jmobius.gameserver.idfactory.IdFactory;
@ -114,7 +114,7 @@ public class AutoSpawnHandler
private void restoreSpawnData()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))

View File

@ -26,7 +26,7 @@ import java.util.Map;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
@ -79,7 +79,7 @@ public class BlockList
public void updateBlockMemos()
{
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
for (int target : _updateMemos)
{
@ -108,7 +108,7 @@ public class BlockList
private static HashMap<Integer, String> loadList(int ObjId)
{
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"))
{
ps.setInt(1, ObjId);
@ -136,7 +136,7 @@ public class BlockList
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"))
{
ps.setInt(1, _owner.getObjectId());
@ -151,7 +151,7 @@ public class BlockList
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)"))
{
ps.setInt(1, _owner.getObjectId());

View File

@ -24,7 +24,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.datatables.SkillData;
@ -138,7 +138,7 @@ public class CursedWeapon implements INamable
// Remove from Db
_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 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.");
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
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 (?, ?, ?, ?, ?, ?)"))
{

View File

@ -34,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.Manager.ForumsBBSManager;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
@ -246,7 +246,7 @@ public class L2Clan implements IIdentifiable, INamable
}
else
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
{
ps.setInt(1, 0);
@ -286,7 +286,7 @@ public class L2Clan implements IIdentifiable, INamable
}
else
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
{
ps.setInt(1, EnumIntBitmask.getAllBitmask(ClanPrivilege.class));
@ -881,7 +881,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, getBloodAllianceCount());
@ -925,7 +925,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, getBloodOathCount());
@ -943,7 +943,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, getReputationScore());
@ -972,7 +972,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, getLeaderId());
@ -1014,7 +1014,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void store()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
{
ps.setInt(1, getId());
@ -1050,7 +1050,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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 ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
@ -1076,7 +1076,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restore()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
{
ps.setInt(1, getId());
@ -1156,7 +1156,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, getId());
@ -1187,7 +1187,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, getId());
@ -1246,7 +1246,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
// 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)
{
@ -1805,7 +1805,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
// Retrieve all subpledges of this clan from the database
@ -1905,7 +1905,7 @@ public class L2Clan implements IIdentifiable, INamable
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 (?,?,?,?)"))
{
ps.setInt(1, getId());
@ -1993,7 +1993,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, getSubPledge(pledgeType).getLeaderId());
@ -2014,7 +2014,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
// Retrieve all skills of this L2PcInstance from the database
@ -2067,7 +2067,7 @@ public class L2Clan implements IIdentifiable, INamable
{
_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 = ?"))
{
// 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));
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 (?,?,?,?)"))
{
// Retrieve all skills of this L2PcInstance from the database
@ -2241,7 +2241,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, id);
@ -2802,7 +2802,7 @@ public class L2Clan implements IIdentifiable, INamable
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 = ?"))
{
ps.setInt(1, level);
@ -2848,7 +2848,7 @@ public class L2Clan implements IIdentifiable, INamable
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 = ?"))
{
ps.setInt(1, crestId);
@ -2885,7 +2885,7 @@ public class L2Clan implements IIdentifiable, INamable
allyId = getAllyId();
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sqlStatement))
{
ps.setInt(1, crestId);
@ -2931,7 +2931,7 @@ public class L2Clan implements IIdentifiable, INamable
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 = ?"))
{
ps.setInt(1, crestId);

View File

@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
@ -264,7 +264,7 @@ public class L2ClanMember
*/
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=?"))
{
ps.setLong(1, _pledgeType);
@ -313,7 +313,7 @@ public class L2ClanMember
*/
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=?"))
{
ps.setLong(1, _powerGrade);
@ -840,7 +840,7 @@ public class L2ClanMember
*/
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=?"))
{
ps.setInt(1, apprentice);

View File

@ -24,7 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
@ -57,7 +57,7 @@ public class L2ContactList
{
_contacts.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_LOAD))
{
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))
{
ps.setInt(1, activeChar.getObjectId());
@ -160,7 +160,7 @@ public class L2ContactList
_contacts.remove(name);
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_REMOVE))
{
ps.setInt(1, activeChar.getObjectId());

View File

@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.util.logging.Level;
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.network.serverpackets.L2GameServerPacket;
@ -49,7 +49,7 @@ public class L2Mentee
final L2PcInstance player = getPlayerInstance();
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 = ?"))
{
ps.setInt(1, getObjectId());

View File

@ -29,7 +29,7 @@ import java.util.StringTokenizer;
import java.util.logging.Level;
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.MacroUpdateType;
import com.l2jmobius.gameserver.enums.ShortcutType;
@ -125,7 +125,7 @@ public class MacroList implements IRestorable
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(?,?,?,?,?,?,?)"))
{
ps.setInt(1, _owner.getObjectId());
@ -161,7 +161,7 @@ public class MacroList implements IRestorable
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=?"))
{
ps.setInt(1, _owner.getObjectId());
@ -178,7 +178,7 @@ public class MacroList implements IRestorable
public boolean restoreMe()
{
_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=?"))
{
ps.setInt(1, _owner.getObjectId());

View File

@ -24,7 +24,7 @@ import java.util.TreeMap;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.interfaces.IRestorable;
@ -89,7 +89,7 @@ public class ShortCuts implements IRestorable
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(?,?,?,?,?,?,?)"))
{
ps.setInt(1, _owner.getObjectId());
@ -209,7 +209,7 @@ public class ShortCuts implements IRestorable
*/
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=?"))
{
ps.setInt(1, _owner.getObjectId());
@ -228,7 +228,7 @@ public class ShortCuts implements IRestorable
public boolean restoreMe()
{
_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=?"))
{
statement.setInt(1, _owner.getObjectId());

View File

@ -25,7 +25,7 @@ import java.util.Map;
import java.util.logging.Level;
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;
/**
@ -104,7 +104,7 @@ public class UIKeysSettings
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
@ -125,7 +125,7 @@ public class UIKeysSettings
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
@ -146,7 +146,7 @@ public class UIKeysSettings
_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`"))
{
ps.setInt(1, _playerObjId);
@ -178,7 +178,7 @@ public class UIKeysSettings
_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`"))
{
ps.setInt(1, _playerObjId);

View File

@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
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.GeoData;
import com.l2jmobius.gameserver.ItemsAutoDestroy;
@ -1397,7 +1397,7 @@ public final class L2PcInstance extends L2Playable
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(?,?,?,?)"))
{
ps.setInt(1, getObjectId());
@ -1414,7 +1414,7 @@ public final class L2PcInstance extends L2Playable
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=?"))
{
ps.setInt(1, getObjectId());
@ -7052,7 +7052,7 @@ public final class L2PcInstance extends L2Playable
*/
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=?"))
{
ps.setInt(1, isOnlineInt());
@ -7072,7 +7072,7 @@ public final class L2PcInstance extends L2Playable
*/
private boolean createDb()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CHARACTER))
{
ps.setString(1, _accountName);
@ -7136,7 +7136,7 @@ public final class L2PcInstance extends L2Playable
double currentCp = 0;
double currentHp = 0;
double currentMp = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER))
{
// 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)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
{
ps.setInt(1, player.getObjectId());
@ -7553,7 +7553,7 @@ public final class L2PcInstance extends L2Playable
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";
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sql))
{
ps.setInt(1, getObjectId());
@ -7606,7 +7606,7 @@ public final class L2PcInstance extends L2Playable
private void loadPremiumItemList()
{
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))
{
ps.setInt(1, getObjectId());
@ -7630,7 +7630,7 @@ public final class L2PcInstance extends L2Playable
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=? "))
{
ps.setLong(1, newcount);
@ -7646,7 +7646,7 @@ public final class L2PcInstance extends L2Playable
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=? "))
{
ps.setInt(1, getObjectId());
@ -7705,7 +7705,7 @@ public final class L2PcInstance extends L2Playable
final long exp = getStat().getBaseExp();
final int level = getStat().getBaseLevel();
final long sp = getStat().getBaseSp();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))
{
ps.setInt(1, level);
@ -7793,7 +7793,7 @@ public final class L2PcInstance extends L2Playable
}
// 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))
{
for (SubClass subClass : getSubClasses().values())
@ -7824,7 +7824,7 @@ public final class L2PcInstance extends L2Playable
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE);
PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE);)
{
@ -7927,7 +7927,7 @@ public final class L2PcInstance extends L2Playable
private void storeItemReuseDelay()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_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);
if (oldSkill != null)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
{
// 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)
{
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
if ((oldSkill != null) && (newSkill != null))
{
@ -8133,7 +8133,7 @@ public final class L2PcInstance extends L2Playable
}
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))
{
con.setAutoCommit(false);
@ -8159,7 +8159,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreSkills()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
{
// Retrieve all skills of this L2PcInstance from the database
@ -8210,7 +8210,7 @@ public final class L2PcInstance extends L2Playable
@Override
public void restoreEffects()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
{
ps.setInt(1, getObjectId());
@ -8267,7 +8267,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreItemReuse()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);)
{
@ -8338,7 +8338,7 @@ public final class L2PcInstance extends L2Playable
_henna[i] = null;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_HENNAS))
{
ps.setInt(1, getObjectId());
@ -8426,7 +8426,7 @@ public final class L2PcInstance extends L2Playable
_henna[slot] = null;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_CHAR_HENNA))
{
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))
{
ps.setInt(1, getObjectId());
@ -10534,7 +10534,7 @@ public final class L2PcInstance extends L2Playable
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))
{
// Store the basic info about this new sub-class.
@ -10601,7 +10601,7 @@ public final class L2PcInstance extends L2Playable
try
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS);
PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE);
@ -13298,7 +13298,7 @@ public final class L2PcInstance extends L2Playable
if ((_controlItemId != 0) && (petId != 0))
{
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))
{
ps.setInt(1, getCurrentFeed());
@ -13450,7 +13450,7 @@ public final class L2PcInstance extends L2Playable
bookmark.setTag(tag);
bookmark.setName(name);
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_TP_BOOKMARK))
{
ps.setInt(1, icon);
@ -13473,7 +13473,7 @@ public final class L2PcInstance extends L2Playable
{
if (_tpbookmarks.remove(id) != null)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_TP_BOOKMARK))
{
ps.setInt(1, getObjectId());
@ -13616,7 +13616,7 @@ public final class L2PcInstance extends L2Playable
sm.addItemName(20033);
sendPacket(sm);
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_TP_BOOKMARK))
{
ps.setInt(1, getObjectId());
@ -13638,7 +13638,7 @@ public final class L2PcInstance extends L2Playable
public void restoreTeleportBookmark()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_TP_BOOKMARK))
{
ps.setInt(1, getObjectId());
@ -13869,7 +13869,7 @@ public final class L2PcInstance extends L2Playable
public void updateMemos()
{
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)
{
@ -13901,7 +13901,7 @@ public final class L2PcInstance extends L2Playable
_friendList.clear();
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))
{
ps.setInt(1, getObjectId());
@ -13949,7 +13949,7 @@ public final class L2PcInstance extends L2Playable
final Friend friend = _friendList.get(friendId);
int bClassId = 0;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE charId=?");)
{
ps.setInt(1, friendId);
@ -13974,7 +13974,7 @@ public final class L2PcInstance extends L2Playable
}
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=?");)
{
ps.setInt(1, friendId);
@ -13997,7 +13997,7 @@ public final class L2PcInstance extends L2Playable
}
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=?");)
{
ps.setInt(1, friend.getClanId());
@ -14088,7 +14088,7 @@ public final class L2PcInstance extends L2Playable
{
if (hasManufactureShop())
{
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
{
@ -14126,7 +14126,7 @@ public final class L2PcInstance extends L2Playable
_manufactureItems.clear();
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
{
ps.setInt(1, getObjectId());
@ -14579,7 +14579,7 @@ public final class L2PcInstance extends L2Playable
*/
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;"))
{
ps.setInt(1, getObjectId());
@ -14619,7 +14619,7 @@ public final class L2PcInstance extends L2Playable
*/
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"))
{
ps.setInt(1, getObjectId());
@ -14643,7 +14643,7 @@ public final class L2PcInstance extends L2Playable
*/
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 (?,?,?,?)"))
{
ps.setInt(1, getObjectId());
@ -14703,7 +14703,7 @@ public final class L2PcInstance extends L2Playable
private static void restorePremiumSystemData(L2PcInstance player, String account)
{
boolean success = false;
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
final PreparedStatement ps = con.prepareStatement(RESTORE_PREMIUMSERVICE);
ps.setString(1, account);

View File

@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.ai.CtrlIntention;
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
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
{
ps.setInt(1, getControlObjectId());
@ -851,7 +851,7 @@ public class L2PetInstance extends L2Summon
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=?"))
{
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 = ?";
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(req))
{
ps.setString(1, getName());
@ -1002,7 +1002,7 @@ public class L2PetInstance extends L2Summon
// Clear list for overwrite
SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
{
@ -1069,7 +1069,7 @@ public class L2PetInstance extends L2Summon
@Override
public void restoreEffects()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
{

View File

@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.sql.impl.CharSummonTable;
@ -224,7 +224,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
// Clear list for overwrite
SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE))
{
// Delete all current stored effects for summon to avoid dupe
@ -302,7 +302,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
{

View File

@ -24,7 +24,7 @@ import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
import com.l2jmobius.commons.database.DatabaseFactory;
/**
* @author UnAfraid
@ -108,7 +108,7 @@ public class Announcement implements IAnnouncement
@Override
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))
{
ps.setInt(1, _type.ordinal());
@ -134,7 +134,7 @@ public class Announcement implements IAnnouncement
@Override
public boolean updateMe()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{
ps.setInt(1, _type.ordinal());
@ -154,7 +154,7 @@ public class Announcement implements IAnnouncement
@Override
public boolean deleteMe()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
{
ps.setInt(1, _id);

View File

@ -25,7 +25,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
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.util.Broadcast;
@ -94,7 +94,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override
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))
{
ps.setInt(1, getType().ordinal());
@ -123,7 +123,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override
public boolean updateMe()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{
ps.setInt(1, getType().ordinal());

View File

@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
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.model.items.L2Item;
@ -159,7 +159,7 @@ public final class Product
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` = ?"))
{
ps.setInt(1, getBuyListId());

View File

@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.enums.AuctionItemType;
@ -162,7 +162,7 @@ public class Auction
/** Load auctions */
private void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?"))
{
ps.setInt(1, getId());
@ -197,7 +197,7 @@ public class Auction
_highestBidderName = "";
_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"))
{
ps.setInt(1, getId());
@ -246,7 +246,7 @@ public class Auction
/** Save Auction Data End */
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 = ?"))
{
ps.setLong(1, _endDate);
@ -344,7 +344,7 @@ public class Auction
*/
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)
{
@ -401,7 +401,7 @@ public class Auction
/** Remove bids */
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=?"))
{
ps.setInt(1, getId());
@ -434,7 +434,7 @@ public class Auction
public void deleteAuctionFromDB()
{
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=?"))
{
ps.setInt(1, _itemId);
@ -490,7 +490,7 @@ public class Auction
*/
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=?"))
{
ps.setInt(1, getId());
@ -519,7 +519,7 @@ public class Auction
public void confirmAuction()
{
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 (?,?,?,?,?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, getId());

View File

@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.xml.impl.CastleData;
@ -219,7 +219,7 @@ public final class Castle extends AbstractResidence
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 (?,?,?,?,?,?)"))
{
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 = ?"))
{
ps.setLong(1, getTreasury());
@ -622,7 +622,7 @@ public final class Castle extends AbstractResidence
@Override
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 ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
{
@ -669,7 +669,7 @@ public final class Castle extends AbstractResidence
/** Load All Functions */
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 = ?"))
{
ps.setInt(1, getResidenceId());
@ -694,7 +694,7 @@ public final class Castle extends AbstractResidence
public void removeFunction(int 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=?"))
{
ps.setInt(1, getResidenceId());
@ -769,7 +769,7 @@ public final class Castle extends AbstractResidence
// This method loads castle door upgrade data from database
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=?"))
{
ps.setInt(1, getResidenceId());
@ -795,7 +795,7 @@ public final class Castle extends AbstractResidence
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=?"))
{
ps.setInt(1, getResidenceId());
@ -820,7 +820,7 @@ public final class Castle extends AbstractResidence
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 (?,?,?)"))
{
ps.setInt(1, doorId);
@ -847,7 +847,7 @@ public final class Castle extends AbstractResidence
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.
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()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
{
ps.setString(1, String.valueOf(getShowNpcCrest()));
@ -1070,7 +1070,7 @@ public final class Castle extends AbstractResidence
{
_ticketBuyCount = count;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
{
ps.setInt(1, _ticketBuyCount);
@ -1093,7 +1093,7 @@ public final class Castle extends AbstractResidence
{
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 (?,?,?)"))
{
ps.setInt(1, getResidenceId());
@ -1120,7 +1120,7 @@ public final class Castle extends AbstractResidence
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=?"))
{
ps.setInt(1, getResidenceId());
@ -1210,7 +1210,7 @@ public final class Castle extends AbstractResidence
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
{
ps.setString(1, side.toString());

View File

@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
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.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.model.L2Clan;
@ -185,7 +185,7 @@ public abstract class ClanHall
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 (?,?,?,?,?,?)"))
{
ps.setInt(1, getId());
@ -443,7 +443,7 @@ public abstract class ClanHall
/** Load All Functions */
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 = ?"))
{
ps.setInt(1, getId());
@ -468,7 +468,7 @@ public abstract class ClanHall
public void removeFunction(int 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=?"))
{
ps.setInt(1, getId());

View File

@ -23,7 +23,7 @@ import java.util.Calendar;
import java.util.logging.Level;
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.model.actor.instance.L2PcInstance;
@ -45,7 +45,7 @@ public class Couple
{
_Id = coupleId;
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
{
ps.setInt(1, _Id);
@ -85,7 +85,7 @@ public class Couple
_weddingDate = Calendar.getInstance();
_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 (?, ?, ?, ?, ?, ?)"))
{
_Id = IdFactory.getInstance().getNextId();
@ -105,7 +105,7 @@ public class Couple
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 = ?"))
{
ps.setBoolean(1, true);
@ -123,7 +123,7 @@ public class Couple
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=?"))
{
ps.setInt(1, _Id);

View File

@ -34,7 +34,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.UpdaterType;
import com.l2jmobius.gameserver.ThreadPoolManager;
@ -219,7 +219,7 @@ public final class Fort extends AbstractResidence
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 (?,?,?,?,?,?)"))
{
ps.setInt(1, getResidenceId());
@ -492,7 +492,7 @@ public final class Fort extends AbstractResidence
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 = ?"))
{
ps.setInt(1, _supplyLvL);
@ -559,7 +559,7 @@ public final class Fort extends AbstractResidence
@Override
protected void load()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
{
ps.setInt(1, getResidenceId());
@ -620,7 +620,7 @@ public final class Fort extends AbstractResidence
/** Load All Functions */
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 = ?"))
{
ps.setInt(1, getResidenceId());
@ -645,7 +645,7 @@ public final class Fort extends AbstractResidence
public void removeFunction(int 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=?"))
{
ps.setInt(1, getResidenceId());
@ -747,7 +747,7 @@ public final class Fort extends AbstractResidence
// This method loads fort door upgrade data from database
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 = ?"))
{
ps.setInt(1, getResidenceId());
@ -767,7 +767,7 @@ public final class Fort extends AbstractResidence
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 = ?"))
{
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)
{
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 (?,?,?,?)"))
{
ps.setInt(1, doorId);
@ -810,7 +810,7 @@ public final class Fort extends AbstractResidence
_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 = ?"))
{
ps.setInt(1, clanId);
@ -1022,7 +1022,7 @@ public final class Fort extends AbstractResidence
{
_state = state;
_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 = ?"))
{
ps.setInt(1, getFortState());
@ -1154,7 +1154,7 @@ public final class Fort extends AbstractResidence
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 = ?"))
{
ps.setInt(1, getResidenceId());
@ -1185,7 +1185,7 @@ public final class Fort extends AbstractResidence
private void initSiegeNpcs()
{
_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"))
{
ps.setInt(1, getResidenceId());
@ -1214,7 +1214,7 @@ public final class Fort extends AbstractResidence
private void initNpcCommanders()
{
_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"))
{
ps.setInt(1, getResidenceId());
@ -1246,7 +1246,7 @@ public final class Fort extends AbstractResidence
_specialEnvoys.clear();
_envoyCastles.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"))
{
ps.setInt(1, getResidenceId());

View File

@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.enums.ChatType;
@ -493,7 +493,7 @@ public class FortSiege implements Siegable
/** Clear all registered siege clans from database for fort */
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=?"))
{
ps.setInt(1, getFort().getResidenceId());
@ -768,7 +768,7 @@ public class FortSiege implements Siegable
private void removeSiegeClan(int clanId)
{
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))
{
ps.setInt(1, getFort().getResidenceId());
@ -982,7 +982,7 @@ public class FortSiege implements Siegable
private void loadSiegeClan()
{
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=?"))
{
ps.setInt(1, getFort().getResidenceId());
@ -1043,7 +1043,7 @@ public class FortSiege implements Siegable
/** Save siege date to database. */
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 = ?"))
{
ps.setLong(1, getSiegeDate().getTimeInMillis());
@ -1067,7 +1067,7 @@ public class FortSiege implements Siegable
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 (?,?)"))
{
ps.setInt(1, clan.getId());

View File

@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
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.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
@ -108,7 +108,7 @@ public class Hero
HERO_DIARY.clear();
HERO_MESSAGE.clear();
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s1 = con.createStatement();
ResultSet rset = s1.executeQuery(GET_HEROES);
PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
@ -206,7 +206,7 @@ public class Hero
*/
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=?"))
{
ps.setInt(1, charId);
@ -228,7 +228,7 @@ public class Hero
{
final List<StatsSet> diary = new ArrayList<>();
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"))
{
ps.setInt(1, charId);
@ -295,7 +295,7 @@ public class Hero
int _losses = 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"))
{
ps.setInt(1, charId);
@ -692,7 +692,7 @@ public class Hero
public void updateHeroes(boolean setDefault)
{
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
if (setDefault)
{
@ -823,7 +823,7 @@ public class Hero
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(?,?,?,?)"))
{
ps.setInt(1, charId);
@ -859,7 +859,7 @@ public class Hero
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{
ps.setString(1, HERO_MESSAGE.get(charId));
@ -874,7 +874,7 @@ public class Hero
private void deleteItemsInDb()
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
s.executeUpdate(DELETE_ITEMS);

View File

@ -31,7 +31,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.data.sql.impl.ClanTable;
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 */
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=?"))
{
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 */
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"))
{
ps.setInt(1, getCastle().getResidenceId());
@ -1026,7 +1026,7 @@ public class Siege implements Siegable
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=?"))
{
ps.setInt(1, getCastle().getResidenceId());
@ -1291,7 +1291,7 @@ public class Siege implements Siegable
/** Load siege clans. */
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=?"))
{
getAttackerClans().clear();
@ -1402,7 +1402,7 @@ public class Siege implements Siegable
_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 = ?"))
{
ps.setLong(1, getSiegeDate().getTimeInMillis());
@ -1431,7 +1431,7 @@ public class Siege implements Siegable
return;
}
try (Connection con = ConnectionFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
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