Sync with L2jServer HighFive Jul 25th 2015.

This commit is contained in:
MobiusDev 2015-07-26 10:59:25 +00:00
parent 83854bc5e5
commit 1fc14085f5
161 changed files with 2288 additions and 2181 deletions

View File

@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.jar"/> <classpathentry kind="lib" path="dist/libs/HikariCP-2.3.8.jar"/>
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.34-bin.jar"/> <classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.34-bin.jar"/>
<classpathentry kind="lib" path="dist/libs/ecj-4.4.jar"/> <classpathentry kind="lib" path="dist/libs/ecj-4.4.jar"/>
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.9.jar"/> <classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.10.jar"/>
<classpathentry including="**/*.java" kind="src" path="dist/game/data/scripts"/> <classpathentry including="**/*.java" kind="src" path="dist/game/data/scripts"/>
<classpathentry kind="src" path="java"/> <classpathentry kind="src" path="java"/>
<classpathentry kind="lib" path="dist/libs/javassist-3.20.0.jar"/>
<classpathentry kind="lib" path="dist/libs/slf4j-api-1.7.12.jar"/>
<classpathentry kind="lib" path="dist/libs/slf4j-jdk14-1.7.12.jar"/>
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.1.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -89,8 +89,8 @@
<manifest> <manifest>
<attribute name="Built-By" value="${user.name}" /> <attribute name="Built-By" value="${user.name}" />
<attribute name="Built-Date" value="${time.stamp}" /> <attribute name="Built-Date" value="${time.stamp}" />
<attribute name="Implementation-URL" value="http://www.l2jserver.com/" /> <attribute name="Implementation-URL" value="http://www.l2jmobius.com/" />
<attribute name="Class-Path" value="../libs/c3p0-0.9.5.jar ../libs/mysql-connector-java-5.1.34-bin.jar" /> <attribute name="Class-Path" value="${manifest.libs}" />
<attribute name="Main-Class" value="com.l2jserver.loginserver.L2LoginServer" /> <attribute name="Main-Class" value="com.l2jserver.loginserver.L2LoginServer" />
</manifest> </manifest>
</jar> </jar>
@ -104,7 +104,7 @@
<manifest> <manifest>
<attribute name="Built-By" value="${user.name}" /> <attribute name="Built-By" value="${user.name}" />
<attribute name="Built-Date" value="${time.stamp}" /> <attribute name="Built-Date" value="${time.stamp}" />
<attribute name="Implementation-URL" value="http://www.l2jserver.com/" /> <attribute name="Implementation-URL" value="http://www.l2jmobius.com/" />
<attribute name="Class-Path" value="${manifest.libs}" /> <attribute name="Class-Path" value="${manifest.libs}" />
<attribute name="Main-Class" value="com.l2jserver.gameserver.GameServer" /> <attribute name="Main-Class" value="com.l2jserver.gameserver.GameServer" />
</manifest> </manifest>

View File

@ -52,6 +52,11 @@ Login = root
# Database connection password # Database connection password
Password = Password =
# Database Connection Pool
# Default: C3P0
# Available: C3P0, HikariCP, BoneCP
ConnectionPool = C3P0
# Default: 100 # Default: 100
MaximumDbConnections = 500 MaximumDbConnections = 500

View File

@ -21,6 +21,7 @@ package conquerablehalls.RainbowSpringsChateau;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
@ -31,7 +32,7 @@ import java.util.Map;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.sql.impl.ClanTable; import com.l2jserver.gameserver.data.sql.impl.ClanTable;
@ -395,7 +396,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
long count = warDecrees.getCount(); long count = warDecrees.getCount();
_warDecreesCount.put(clan.getId(), count); _warDecreesCount.put(clan.getId(), count);
player.destroyItem("Rainbow Springs Registration", warDecrees, npc, true); player.destroyItem("Rainbow Springs Registration", warDecrees, npc, true);
updateAttacker(clan.getId(), count, false); addAttacker(clan.getId(), count);
html = "messenger_yetti009.htm"; html = "messenger_yetti009.htm";
} }
} }
@ -415,7 +416,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
} }
else else
{ {
updateAttacker(clan.getId(), 0, true); removeAttacker(clan.getId());
html = "messenger_yetti018.htm"; html = "messenger_yetti018.htm";
} }
break; break;
@ -830,34 +831,31 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
private static boolean isYetiTarget(int npcId) private static boolean isYetiTarget(int npcId)
{ {
for (int yeti : YETIS) return Util.contains(YETIS, npcId);
{
if (yeti == npcId)
{
return true;
}
}
return false;
} }
private static void updateAttacker(int clanId, long count, boolean remove) private static void removeAttacker(int clanId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?"))
{ {
PreparedStatement statement; ps.setInt(1, clanId);
if (remove) ps.execute();
{ }
statement = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?"); catch (Exception e)
statement.setInt(1, clanId); {
} e.printStackTrace();
else }
{ }
statement = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)");
statement.setInt(1, clanId); private static void addAttacker(int clanId, long count)
statement.setLong(2, count); {
} try (Connection con = ConnectionFactory.getInstance().getConnection();
statement.execute(); PreparedStatement ps = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)"))
statement.close(); {
ps.setInt(1, clanId);
ps.setLong(2, count);
ps.execute();
} }
catch (Exception e) catch (Exception e)
{ {
@ -868,18 +866,16 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
@Override @Override
public void loadAttackers() public void loadAttackers()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement())
{ {
PreparedStatement statement = con.prepareStatement("SELECT * FROM rainbowsprings_attacker_list"); try (ResultSet rset = s.executeQuery("SELECT * FROM rainbowsprings_attacker_list"))
ResultSet rset = statement.executeQuery();
while (rset.next())
{ {
int clanId = rset.getInt("clan_id"); while (rset.next())
long count = rset.getLong("decrees_count"); {
_warDecreesCount.put(clanId, count); _warDecreesCount.put(rset.getInt("clan_id"), rset.getLong("decrees_count"));
}
} }
rset.close();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.ai.L2SpecialSiegeGuardAI; import com.l2jserver.gameserver.ai.L2SpecialSiegeGuardAI;
@ -764,135 +764,123 @@ public abstract class FlagWar extends ClanHallSiegeEngine
@Override @Override
public final void loadAttackers() public final void loadAttackers()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{ {
PreparedStatement statement = con.prepareStatement(SQL_LOAD_ATTACKERS); ps.setInt(1, _hall.getId());
statement.setInt(1, _hall.getId()); try (ResultSet rset = ps.executeQuery())
ResultSet rset = statement.executeQuery();
while (rset.next())
{ {
final int clanId = rset.getInt("clan_id"); while (rset.next())
if (ClanTable.getInstance().getClan(clanId) == null)
{ {
_log.warning(getName() + ": Loaded an unexistent clan as attacker! Clan ID: " + clanId); final int clanId = rset.getInt("clan_id");
continue;
if (ClanTable.getInstance().getClan(clanId) == null)
{
_log.warning(getName() + ": Loaded an unexistent clan as attacker! Clan ID: " + clanId);
continue;
}
ClanData data = new ClanData();
data.flag = rset.getInt("flag");
data.npc = rset.getInt("npc");
_data.put(clanId, data);
loadAttackerMembers(clanId);
} }
ClanData data = new ClanData();
data.flag = rset.getInt("flag");
data.npc = rset.getInt("npc");
_data.put(clanId, data);
loadAttackerMembers(clanId);
} }
rset.close();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning(getName() + ".loadAttackers()->" + e.getMessage()); _log.warning(getName() + ".loadAttackers()->" + e.getMessage());
e.printStackTrace();
} }
} }
private final void loadAttackerMembers(int clanId) private final void loadAttackerMembers(int clanId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) final List<Integer> listInstance = _data.get(clanId).players;
if (listInstance == null)
{ {
ArrayList<Integer> listInstance = _data.get(clanId).players; _log.warning(getName() + ": Tried to load unregistered clan with ID " + clanId);
return;
if (listInstance == null) }
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_MEMEBERS))
{
ps.setInt(1, clanId);
try (ResultSet rset = ps.executeQuery())
{ {
_log.warning(getName() + ": Tried to load unregistered clan with ID " + clanId); while (rset.next())
return; {
listInstance.add(rset.getInt("object_id"));
}
} }
PreparedStatement statement = con.prepareStatement(SQL_LOAD_MEMEBERS);
statement.setInt(1, clanId);
ResultSet rset = statement.executeQuery();
while (rset.next())
{
listInstance.add(rset.getInt("object_id"));
}
rset.close();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning(getName() + ".loadAttackerMembers()->" + e.getMessage()); _log.warning(getName() + ".loadAttackerMembers()->" + e.getMessage());
e.printStackTrace();
} }
} }
private final void saveClan(int clanId, int flag) private final void saveClan(int clanId, int flag)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_CLAN))
{ {
PreparedStatement statement = con.prepareStatement(SQL_SAVE_CLAN); ps.setInt(1, _hall.getId());
statement.setInt(1, _hall.getId()); ps.setInt(2, flag);
statement.setInt(2, flag); ps.setInt(3, 0);
statement.setInt(3, 0); ps.setInt(4, clanId);
statement.setInt(4, clanId); ps.execute();
statement.execute();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning(getName() + ".saveClan()->" + e.getMessage()); _log.warning(getName() + ".saveClan()->" + e.getMessage());
e.printStackTrace();
} }
} }
private final void saveNpc(int npc, int clanId) private final void saveNpc(int npc, int clanId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_NPC))
{ {
PreparedStatement statement = con.prepareStatement(SQL_SAVE_NPC); ps.setInt(1, npc);
statement.setInt(1, npc); ps.setInt(2, clanId);
statement.setInt(2, clanId); ps.execute();
statement.execute();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning(getName() + ".saveNpc()->" + e.getMessage()); _log.warning(getName() + ".saveNpc()->" + e.getMessage());
e.printStackTrace();
} }
} }
private final void saveMember(int clanId, int objectId) private final void saveMember(int clanId, int objectId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE_ATTACKER))
{ {
PreparedStatement statement = con.prepareStatement(SQL_SAVE_ATTACKER); ps.setInt(1, _hall.getId());
statement.setInt(1, _hall.getId()); ps.setInt(2, clanId);
statement.setInt(2, clanId); ps.setInt(3, objectId);
statement.setInt(3, objectId); ps.execute();
statement.execute();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning(getName() + ".saveMember()->" + e.getMessage()); _log.warning(getName() + ".saveMember()->" + e.getMessage());
e.printStackTrace();
} }
} }
private void clearTables() private void clearTables()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(SQL_CLEAR_CLAN);
PreparedStatement ps2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS))
{ {
PreparedStatement stat1 = con.prepareStatement(SQL_CLEAR_CLAN); ps1.setInt(1, _hall.getId());
stat1.setInt(1, _hall.getId()); ps1.execute();
stat1.execute();
stat1.close();
PreparedStatement stat2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS); ps2.setInt(1, _hall.getId());
stat2.setInt(1, _hall.getId()); ps2.execute();
stat2.execute();
stat2.close();
} }
catch (Exception e) catch (Exception e)
{ {
@ -904,8 +892,8 @@ public abstract class FlagWar extends ClanHallSiegeEngine
{ {
int flag = 0; int flag = 0;
int npc = 0; int npc = 0;
ArrayList<Integer> players = new ArrayList<>(18); List<Integer> players = new ArrayList<>(18);
ArrayList<L2PcInstance> playersInstance = new ArrayList<>(18); List<L2PcInstance> playersInstance = new ArrayList<>(18);
L2Spawn warrior = null; L2Spawn warrior = null;
L2Spawn flagInstance = null; L2Spawn flagInstance = null;
} }

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.xml.impl.AdminData; import com.l2jserver.gameserver.data.xml.impl.AdminData;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.L2AccessLevel; import com.l2jserver.gameserver.model.L2AccessLevel;
@ -75,15 +75,14 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
} }
else else
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
{ {
PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"); ps.setInt(1, lvl);
statement.setInt(1, lvl); ps.setString(2, name);
statement.setString(2, name); ps.execute();
statement.execute();
int count = statement.getUpdateCount(); if (ps.getUpdateCount() == 0)
statement.close();
if (count == 0)
{ {
activeChar.sendMessage("Character not found or access level unaltered."); activeChar.sendMessage("Character not found or access level unaltered.");
} }

View File

@ -30,7 +30,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable; import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.data.xml.impl.ClassListData; import com.l2jserver.gameserver.data.xml.impl.ClassListData;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
@ -557,11 +557,13 @@ public class AdminEditChar implements IAdminCommandHandler
if (player == null) if (player == null)
{ {
Connection con = L2DatabaseFactory.getInstance().getConnection(); final String updateQuery = "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1";
PreparedStatement ps = con.prepareStatement("UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1"); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(updateQuery))
ps.setString(1, playerName); {
ps.execute(); ps.setString(1, playerName);
ps.execute();
}
} }
else else
{ {

View File

@ -20,11 +20,11 @@ package handlers.admincommandhandlers;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -63,47 +63,36 @@ public class AdminRepairChar implements IAdminCommandHandler
return; return;
} }
final String playerName = parts[1];
String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?"; String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement(cmd); try (PreparedStatement ps = con.prepareStatement(cmd))
statement.setString(1, parts[1]);
statement.execute();
statement.close();
statement = con.prepareStatement("SELECT charId FROM characters where char_name=?");
statement.setString(1, parts[1]);
ResultSet rset = statement.executeQuery();
int objId = 0;
if (rset.next())
{ {
objId = rset.getInt(1); ps.setString(1, playerName);
ps.execute();
} }
rset.close(); final int objId = CharNameTable.getInstance().getIdByName(playerName);
statement.close(); if (objId != 0)
if (objId == 0)
{ {
con.close(); // Delete player's shortcuts.
return; try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?"))
{
ps.setInt(1, objId);
ps.execute();
}
// Move all items to the inventory.
try (PreparedStatement ps = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?"))
{
ps.setInt(1, objId);
ps.execute();
}
} }
// connection = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
statement.setInt(1, objId);
statement.execute();
statement.close();
// connection = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
statement.setInt(1, objId);
statement.execute();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.log(Level.WARNING, "could not repair char:", e); _log.log(Level.WARNING, "Could not repair char:", e);
} }
} }
} }

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.instancemanager.QuestManager; import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.model.L2Object; import com.l2jserver.gameserver.model.L2Object;
@ -174,7 +174,8 @@ public class AdminShowQuests implements IAdminCommandHandler
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val) private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) // TODO(Zoey76): Refactor this into smaller methods and separate database access logic from HTML creation.
try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
ResultSet rs; ResultSet rs;
PreparedStatement req; PreparedStatement req;

View File

@ -26,7 +26,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.datatables.SpawnTable; import com.l2jserver.gameserver.datatables.SpawnTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
@ -510,16 +510,16 @@ public class AdminTeleport implements IAdminCommandHandler
final int x = activeChar.getX(); final int x = activeChar.getX();
final int y = activeChar.getY(); final int y = activeChar.getY();
final int z = activeChar.getZ(); final int z = activeChar.getZ();
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"))
{ {
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"); ps.setInt(1, x);
statement.setInt(1, x); ps.setInt(2, y);
statement.setInt(2, y); ps.setInt(3, z);
statement.setInt(3, z); ps.setString(4, name);
statement.setString(4, name); ps.execute();
statement.execute(); int count = ps.getUpdateCount();
int count = statement.getUpdateCount();
statement.close();
if (count == 0) if (count == 0)
{ {
activeChar.sendMessage("Character not found or position unaltered."); activeChar.sendMessage("Character not found or position unaltered.");

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler; import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IParseBoardHandler; import com.l2jserver.gameserver.handler.IParseBoardHandler;
@ -63,7 +63,7 @@ public class FavoriteBoard implements IParseBoardHandler
// Load Favorite links // Load Favorite links
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html"); final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html");
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES)) PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@ -100,7 +100,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false; return false;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE)) PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@ -125,7 +125,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false; return false;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE)) PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.sql.impl.ClanTable; import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.data.xml.impl.BuyListData; import com.l2jserver.gameserver.data.xml.impl.BuyListData;
@ -178,7 +178,7 @@ public final class HomeBoard implements IParseBoardHandler
private static int getFavoriteCount(L2PcInstance player) private static int getFavoriteCount(L2PcInstance player)
{ {
int count = 0; int count = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES)) PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
{ {
ps.setInt(1, player.getObjectId()); ps.setInt(1, player.getObjectId());

View File

@ -24,7 +24,7 @@ import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.handler.IUserCommandHandler; import com.l2jserver.gameserver.handler.IUserCommandHandler;
import com.l2jserver.gameserver.model.L2Clan; import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -64,57 +64,53 @@ public class ClanWarsList implements IUserCommandHandler
return false; return false;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) String query;
// Attack List
if (id == 88)
{ {
String query; activeChar.sendPacket(SystemMessageId.CLANS_YOU_VE_DECLARED_WAR_ON);
// Attack List query = ATTACK_LIST;
if (id == 88) }
{ // Under Attack List
activeChar.sendPacket(SystemMessageId.CLANS_YOU_VE_DECLARED_WAR_ON); else if (id == 89)
query = ATTACK_LIST; {
} activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU);
// Under Attack List query = UNDER_ATTACK_LIST;
else if (id == 89) }
{ // War List
activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU); else
query = UNDER_ATTACK_LIST; {
} activeChar.sendPacket(SystemMessageId.CLAN_WAR_LIST);
// War List query = WAR_LIST;
else }
{
activeChar.sendPacket(SystemMessageId.CLAN_WAR_LIST); try (Connection con = ConnectionFactory.getInstance().getConnection();
query = WAR_LIST; PreparedStatement ps = con.prepareStatement(query))
} {
ps.setInt(1, clan.getId());
ps.setInt(2, clan.getId());
try (PreparedStatement ps = con.prepareStatement(query)) SystemMessage sm;
try (ResultSet rs = ps.executeQuery())
{ {
ps.setInt(1, clan.getId()); while (rs.next())
ps.setInt(2, clan.getId());
SystemMessage sm;
try (ResultSet rs = ps.executeQuery())
{ {
String clanName; String clanName = rs.getString("clan_name");
int ally_id; int allyId = rs.getInt("ally_id");
while (rs.next()) if (allyId > 0)
{ {
clanName = rs.getString("clan_name"); // Target With Ally
ally_id = rs.getInt("ally_id"); sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
if (ally_id > 0) sm.addString(clanName);
{ sm.addString(rs.getString("ally_name"));
// Target With Ally
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
sm.addString(clanName);
sm.addString(rs.getString("ally_name"));
}
else
{
// Target Without Ally
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLIANCE_EXISTS);
sm.addString(clanName);
}
activeChar.sendPacket(sm);
} }
else
{
// Target Without Ally
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLIANCE_EXISTS);
sm.addString(clanName);
}
activeChar.sendPacket(sm);
} }
} }
activeChar.sendPacket(SystemMessageId.EMPTY3); activeChar.sendPacket(SystemMessageId.EMPTY3);

View File

@ -25,7 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.GameTimeController; import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.ai.CtrlIntention;
@ -209,30 +209,29 @@ public class Wedding implements IVoicedCommandHandler
return false; return false;
} }
// check if target has player on friendlist // Check if target has player on friend list
boolean FoundOnFriendList = false; boolean foundOnFriendList = false;
int objectId; try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?"))
{ {
final PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?");
statement.setInt(1, ptarget.getObjectId()); statement.setInt(1, ptarget.getObjectId());
final ResultSet rset = statement.executeQuery(); try (ResultSet rset = statement.executeQuery())
while (rset.next())
{ {
objectId = rset.getInt("friendId"); while (rset.next())
if (objectId == activeChar.getObjectId())
{ {
FoundOnFriendList = true; if (rset.getInt("friendId") == activeChar.getObjectId())
{
foundOnFriendList = true;
}
} }
} }
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning("could not read friend data:" + e); _log.warning("could not read friend data:" + e);
} }
if (!FoundOnFriendList) if (!foundOnFriendList)
{ {
activeChar.sendMessage("The player you want to ask is not on your friends list, you must first be on each others friends list before you choose to engage."); activeChar.sendMessage("The player you want to ask is not on your friends list, you must first be on each others friends list before you choose to engage.");
return false; return false;

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.xml.impl.AdminData; import com.l2jserver.gameserver.data.xml.impl.AdminData;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.L2AccessLevel; import com.l2jserver.gameserver.model.L2AccessLevel;
@ -75,15 +75,14 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
} }
else else
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
{ {
PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"); ps.setInt(1, lvl);
statement.setInt(1, lvl); ps.setString(2, name);
statement.setString(2, name); ps.execute();
statement.execute();
int count = statement.getUpdateCount(); if (ps.getUpdateCount() == 0)
statement.close();
if (count == 0)
{ {
activeChar.sendMessage("Character not found or access level unaltered."); activeChar.sendMessage("Character not found or access level unaltered.");
} }

View File

@ -30,7 +30,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable; import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.data.xml.impl.ClassListData; import com.l2jserver.gameserver.data.xml.impl.ClassListData;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
@ -557,11 +557,13 @@ public class AdminEditChar implements IAdminCommandHandler
if (player == null) if (player == null)
{ {
Connection con = L2DatabaseFactory.getInstance().getConnection(); final String updateQuery = "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1";
PreparedStatement ps = con.prepareStatement("UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1"); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(updateQuery))
ps.setString(1, playerName); {
ps.execute(); ps.setString(1, playerName);
ps.execute();
}
} }
else else
{ {

View File

@ -20,11 +20,11 @@ package handlers.admincommandhandlers;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -63,47 +63,36 @@ public class AdminRepairChar implements IAdminCommandHandler
return; return;
} }
final String playerName = parts[1];
String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?"; String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement(cmd); try (PreparedStatement ps = con.prepareStatement(cmd))
statement.setString(1, parts[1]);
statement.execute();
statement.close();
statement = con.prepareStatement("SELECT charId FROM characters where char_name=?");
statement.setString(1, parts[1]);
ResultSet rset = statement.executeQuery();
int objId = 0;
if (rset.next())
{ {
objId = rset.getInt(1); ps.setString(1, playerName);
ps.execute();
} }
rset.close(); final int objId = CharNameTable.getInstance().getIdByName(playerName);
statement.close(); if (objId != 0)
if (objId == 0)
{ {
con.close(); // Delete player's shortcuts.
return; try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?"))
{
ps.setInt(1, objId);
ps.execute();
}
// Move all items to the inventory.
try (PreparedStatement ps = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?"))
{
ps.setInt(1, objId);
ps.execute();
}
} }
// connection = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
statement.setInt(1, objId);
statement.execute();
statement.close();
// connection = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
statement.setInt(1, objId);
statement.execute();
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.log(Level.WARNING, "could not repair char:", e); _log.log(Level.WARNING, "Could not repair char:", e);
} }
} }
} }

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.instancemanager.QuestManager; import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.model.L2Object; import com.l2jserver.gameserver.model.L2Object;
@ -174,7 +174,8 @@ public class AdminShowQuests implements IAdminCommandHandler
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val) private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) // TODO(Zoey76): Refactor this into smaller methods and separate database access logic from HTML creation.
try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
ResultSet rs; ResultSet rs;
PreparedStatement req; PreparedStatement req;

View File

@ -26,7 +26,7 @@ import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.datatables.SpawnTable; import com.l2jserver.gameserver.datatables.SpawnTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler; import com.l2jserver.gameserver.handler.IAdminCommandHandler;
@ -510,16 +510,16 @@ public class AdminTeleport implements IAdminCommandHandler
final int x = activeChar.getX(); final int x = activeChar.getX();
final int y = activeChar.getY(); final int y = activeChar.getY();
final int z = activeChar.getZ(); final int z = activeChar.getZ();
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"))
{ {
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"); ps.setInt(1, x);
statement.setInt(1, x); ps.setInt(2, y);
statement.setInt(2, y); ps.setInt(3, z);
statement.setInt(3, z); ps.setString(4, name);
statement.setString(4, name); ps.execute();
statement.execute(); int count = ps.getUpdateCount();
int count = statement.getUpdateCount();
statement.close();
if (count == 0) if (count == 0)
{ {
activeChar.sendMessage("Character not found or position unaltered."); activeChar.sendMessage("Character not found or position unaltered.");

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler; import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IParseBoardHandler; import com.l2jserver.gameserver.handler.IParseBoardHandler;
@ -63,7 +63,7 @@ public class FavoriteBoard implements IParseBoardHandler
// Load Favorite links // Load Favorite links
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html"); final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html");
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES)) PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@ -100,7 +100,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false; return false;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE)) PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@ -125,7 +125,7 @@ public class FavoriteBoard implements IParseBoardHandler
return false; return false;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE)) PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());

View File

@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.sql.impl.ClanTable; import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.data.xml.impl.BuyListData; import com.l2jserver.gameserver.data.xml.impl.BuyListData;
@ -178,7 +178,7 @@ public final class HomeBoard implements IParseBoardHandler
private static int getFavoriteCount(L2PcInstance player) private static int getFavoriteCount(L2PcInstance player)
{ {
int count = 0; int count = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES)) PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
{ {
ps.setInt(1, player.getObjectId()); ps.setInt(1, player.getObjectId());

View File

@ -24,7 +24,7 @@ import java.sql.ResultSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.handler.IUserCommandHandler; import com.l2jserver.gameserver.handler.IUserCommandHandler;
import com.l2jserver.gameserver.model.L2Clan; import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -64,57 +64,53 @@ public class ClanWarsList implements IUserCommandHandler
return false; return false;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) String query;
// Attack List
if (id == 88)
{ {
String query; activeChar.sendPacket(SystemMessageId.CLANS_YOU_VE_DECLARED_WAR_ON);
// Attack List query = ATTACK_LIST;
if (id == 88) }
{ // Under Attack List
activeChar.sendPacket(SystemMessageId.CLANS_YOU_VE_DECLARED_WAR_ON); else if (id == 89)
query = ATTACK_LIST; {
} activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU);
// Under Attack List query = UNDER_ATTACK_LIST;
else if (id == 89) }
{ // War List
activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU); else
query = UNDER_ATTACK_LIST; {
} activeChar.sendPacket(SystemMessageId.CLAN_WAR_LIST);
// War List query = WAR_LIST;
else }
{
activeChar.sendPacket(SystemMessageId.CLAN_WAR_LIST); try (Connection con = ConnectionFactory.getInstance().getConnection();
query = WAR_LIST; PreparedStatement ps = con.prepareStatement(query))
} {
ps.setInt(1, clan.getId());
ps.setInt(2, clan.getId());
try (PreparedStatement ps = con.prepareStatement(query)) SystemMessage sm;
try (ResultSet rs = ps.executeQuery())
{ {
ps.setInt(1, clan.getId()); while (rs.next())
ps.setInt(2, clan.getId());
SystemMessage sm;
try (ResultSet rs = ps.executeQuery())
{ {
String clanName; String clanName = rs.getString("clan_name");
int ally_id; int allyId = rs.getInt("ally_id");
while (rs.next()) if (allyId > 0)
{ {
clanName = rs.getString("clan_name"); // Target With Ally
ally_id = rs.getInt("ally_id"); sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
if (ally_id > 0) sm.addString(clanName);
{ sm.addString(rs.getString("ally_name"));
// Target With Ally
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
sm.addString(clanName);
sm.addString(rs.getString("ally_name"));
}
else
{
// Target Without Ally
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLIANCE_EXISTS);
sm.addString(clanName);
}
activeChar.sendPacket(sm);
} }
else
{
// Target Without Ally
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLIANCE_EXISTS);
sm.addString(clanName);
}
activeChar.sendPacket(sm);
} }
} }
activeChar.sendPacket(SystemMessageId.EMPTY3); activeChar.sendPacket(SystemMessageId.EMPTY3);

View File

@ -25,7 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.GameTimeController; import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention; import com.l2jserver.gameserver.ai.CtrlIntention;
@ -209,30 +209,29 @@ public class Wedding implements IVoicedCommandHandler
return false; return false;
} }
// check if target has player on friendlist // Check if target has player on friend list
boolean FoundOnFriendList = false; boolean foundOnFriendList = false;
int objectId; try (Connection con = ConnectionFactory.getInstance().getConnection();
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?"))
{ {
final PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?");
statement.setInt(1, ptarget.getObjectId()); statement.setInt(1, ptarget.getObjectId());
final ResultSet rset = statement.executeQuery(); try (ResultSet rset = statement.executeQuery())
while (rset.next())
{ {
objectId = rset.getInt("friendId"); while (rset.next())
if (objectId == activeChar.getObjectId())
{ {
FoundOnFriendList = true; if (rset.getInt("friendId") == activeChar.getObjectId())
{
foundOnFriendList = true;
}
} }
} }
statement.close();
} }
catch (Exception e) catch (Exception e)
{ {
_log.warning("could not read friend data:" + e); _log.warning("could not read friend data:" + e);
} }
if (!FoundOnFriendList) if (!foundOnFriendList)
{ {
activeChar.sendMessage("The player you want to ask is not on your friends list, you must first be on each others friends list before you choose to engage."); activeChar.sendMessage("The player you want to ask is not on your friends list, you must first be on each others friends list before you choose to engage.");
return false; return false;

BIN
trunk/dist/libs/HikariCP-2.3.8.jar vendored Normal file

Binary file not shown.

BIN
trunk/dist/libs/c3p0-0.9.5.1.jar vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
trunk/dist/libs/javassist-3.20.0.jar vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
trunk/dist/libs/slf4j-api-1.7.12.jar vendored Normal file

Binary file not shown.

BIN
trunk/dist/libs/slf4j-jdk14-1.7.12.jar vendored Normal file

Binary file not shown.

View File

@ -82,6 +82,11 @@ Login = root
# Database connection password # Database connection password
Password = Password =
# Database Connection Pool
# Default: C3P0
# Available: C3P0, HikariCP, BoneCP
ConnectionPool = C3P0
# Default: 10 # Default: 10
MaximumDbConnections = 50 MaximumDbConnections = 50

View File

@ -969,6 +969,7 @@ public final class Config
public static String DATABASE_URL; public static String DATABASE_URL;
public static String DATABASE_LOGIN; public static String DATABASE_LOGIN;
public static String DATABASE_PASSWORD; public static String DATABASE_PASSWORD;
public static String DATABASE_CONNECTION_POOL;
public static int DATABASE_MAX_CONNECTIONS; public static int DATABASE_MAX_CONNECTIONS;
public static int DATABASE_MAX_IDLE_TIME; public static int DATABASE_MAX_IDLE_TIME;
public static int MAXIMUM_ONLINE_USERS; public static int MAXIMUM_ONLINE_USERS;
@ -1181,6 +1182,7 @@ public final class Config
DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jgs"); DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jgs");
DATABASE_LOGIN = serverSettings.getString("Login", "root"); DATABASE_LOGIN = serverSettings.getString("Login", "root");
DATABASE_PASSWORD = serverSettings.getString("Password", ""); DATABASE_PASSWORD = serverSettings.getString("Password", "");
DATABASE_CONNECTION_POOL = serverSettings.getString("ConnectionPool", "C3P0");
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 10); DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 10);
DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0); DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0);
@ -2919,6 +2921,7 @@ public final class Config
DATABASE_URL = ServerSettings.getString("URL", "jdbc:mysql://localhost/l2jls"); DATABASE_URL = ServerSettings.getString("URL", "jdbc:mysql://localhost/l2jls");
DATABASE_LOGIN = ServerSettings.getString("Login", "root"); DATABASE_LOGIN = ServerSettings.getString("Login", "root");
DATABASE_PASSWORD = ServerSettings.getString("Password", ""); DATABASE_PASSWORD = ServerSettings.getString("Password", "");
DATABASE_CONNECTION_POOL = ServerSettings.getString("ConnectionPool", "C3P0");
DATABASE_MAX_CONNECTIONS = ServerSettings.getInt("MaximumDbConnections", 10); DATABASE_MAX_CONNECTIONS = ServerSettings.getInt("MaximumDbConnections", 10);
DATABASE_MAX_IDLE_TIME = ServerSettings.getInt("MaximumDbIdleTime", 0); DATABASE_MAX_IDLE_TIME = ServerSettings.getInt("MaximumDbIdleTime", 0);
CONNECTION_CLOSE_TIME = ServerSettings.getLong("ConnectionCloseTime", 60000); CONNECTION_CLOSE_TIME = ServerSettings.getLong("ConnectionCloseTime", 60000);

View File

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

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.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
{
/** The logger. */
protected 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

@ -0,0 +1,48 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.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

@ -0,0 +1,62 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.commons.database.pool.impl;
import javax.sql.DataSource;
import com.l2jserver.commons.database.pool.AbstractConnectionFactory;
import com.l2jserver.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 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

@ -0,0 +1,143 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.commons.database.pool.impl;
import java.beans.PropertyVetoException;
import java.sql.SQLException;
import javax.sql.DataSource;
import com.l2jserver.Config;
import com.l2jserver.commons.database.pool.AbstractConnectionFactory;
import com.l2jserver.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>
* @author Zoey76
*/
final class C3P0ConnectionFactory extends AbstractConnectionFactory
{
private final ComboPooledDataSource _dataSource;
public C3P0ConnectionFactory()
{
if (Config.DATABASE_MAX_CONNECTIONS < 2)
{
Config.DATABASE_MAX_CONNECTIONS = 2;
LOG.warning("A minimum of " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
}
_dataSource = new ComboPooledDataSource();
_dataSource.setAutoCommitOnClose(true);
_dataSource.setInitialPoolSize(10);
_dataSource.setMinPoolSize(10);
_dataSource.setMaxPoolSize(Math.max(10, Config.DATABASE_MAX_CONNECTIONS));
_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.
// this "connection_test_table" is automatically created if not already there
_dataSource.setAutomaticTestTable("connection_test_table");
_dataSource.setTestConnectionOnCheckin(false);
// testing OnCheckin used with IdleConnectionTestPeriod is faster than testing on checkout
_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
// 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
try
{
_dataSource.setDriverClass(Config.DATABASE_DRIVER);
}
catch (PropertyVetoException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
_dataSource.setJdbcUrl(Config.DATABASE_URL);
_dataSource.setUser(Config.DATABASE_LOGIN);
_dataSource.setPassword(Config.DATABASE_PASSWORD);
/* Test the connection */
try
{
_dataSource.getConnection().close();
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if (Config.DEBUG)
{
LOG.fine("Database Connection Working");
}
}
@Override
public void close()
{
try
{
_dataSource.close();
}
catch (Exception e)
{
LOG.info(e.getMessage());
}
}
@Override
public DataSource getDataSource()
{
return _dataSource;
}
public static IConnectionFactory getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final IConnectionFactory INSTANCE = new C3P0ConnectionFactory();
}
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.commons.database.pool.impl;
import com.l2jserver.Config;
import com.l2jserver.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

@ -0,0 +1,76 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.commons.database.pool.impl;
import javax.sql.DataSource;
import com.l2jserver.Config;
import com.l2jserver.commons.database.pool.AbstractConnectionFactory;
import com.l2jserver.commons.database.pool.IConnectionFactory;
import com.zaxxer.hikari.HikariDataSource;
/**
* 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><br>
* <b><font color="RED" size="3">Totally BETA and untested feature!</font></b>
* @author Zoey76
*/
final class HikariCPConnectionFactory extends AbstractConnectionFactory
{
private final HikariDataSource _dataSource;
public HikariCPConnectionFactory()
{
_dataSource = new HikariDataSource();
_dataSource.setJdbcUrl(Config.DATABASE_URL);
_dataSource.setUsername(Config.DATABASE_LOGIN);
_dataSource.setPassword(Config.DATABASE_PASSWORD);
_dataSource.setMaximumPoolSize(Config.DATABASE_MAX_CONNECTIONS);
}
@Override
public void close()
{
try
{
_dataSource.close();
}
catch (Exception e)
{
LOG.info(e.getMessage());
}
}
@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

@ -34,8 +34,8 @@ import commons.mmocore.SelectorConfig;
import commons.mmocore.SelectorThread; import commons.mmocore.SelectorThread;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.Server; import com.l2jserver.Server;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache; import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.sql.impl.AnnouncementsTable; import com.l2jserver.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable; import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
@ -516,7 +516,7 @@ public final class GameServer
// Initialize config // Initialize config
Config.load(); Config.load();
printSection("Database"); printSection("Database");
L2DatabaseFactory.getInstance(); ConnectionFactory.getInstance();
gameServer = new GameServer(); gameServer = new GameServer();
if (Config.IS_TELNET_ENABLED) if (Config.IS_TELNET_ENABLED)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.xml.impl.NpcData; import com.l2jserver.gameserver.data.xml.impl.NpcData;
import com.l2jserver.gameserver.data.xml.impl.PetDataTable; import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
import com.l2jserver.gameserver.datatables.SkillData; import com.l2jserver.gameserver.datatables.SkillData;
@ -72,7 +72,7 @@ public class CharSummonTable
{ {
if (Config.RESTORE_SERVITOR_ON_RECONNECT) if (Config.RESTORE_SERVITOR_ON_RECONNECT)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_SUMMONS)) ResultSet rs = s.executeQuery(INIT_SUMMONS))
{ {
@ -89,7 +89,7 @@ public class CharSummonTable
if (Config.RESTORE_PET_ON_RECONNECT) if (Config.RESTORE_PET_ON_RECONNECT)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_PET)) ResultSet rs = s.executeQuery(INIT_PET))
{ {
@ -113,7 +113,7 @@ public class CharSummonTable
return !v.isEmpty() ? v : null; return !v.isEmpty() ? v : null;
}); });
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON)) PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@ -183,7 +183,7 @@ public class CharSummonTable
public void restoreServitor(L2PcInstance activeChar) public void restoreServitor(L2PcInstance activeChar)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(LOAD_SUMMON)) PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@ -229,7 +229,7 @@ public class CharSummonTable
_servitors.computeIfAbsent(summon.getOwner().getObjectId(), k -> ConcurrentHashMap.newKeySet()).add(summon.getObjectId()); _servitors.computeIfAbsent(summon.getOwner().getObjectId(), k -> ConcurrentHashMap.newKeySet()).add(summon.getObjectId());
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SAVE_SUMMON)) PreparedStatement ps = con.prepareStatement(SAVE_SUMMON))
{ {
ps.setInt(1, summon.getOwner().getObjectId()); ps.setInt(1, summon.getOwner().getObjectId());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.clan.entry.PledgeApplicantInfo; import com.l2jserver.gameserver.model.clan.entry.PledgeApplicantInfo;
import com.l2jserver.gameserver.model.clan.entry.PledgeRecruitInfo; import com.l2jserver.gameserver.model.clan.entry.PledgeRecruitInfo;
@ -93,7 +93,7 @@ public class ClanEntryManager
private final void load() private final void load()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit")) ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit"))
{ {
@ -108,7 +108,7 @@ public class ClanEntryManager
_log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage()); _log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage());
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId")) ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId"))
{ {
@ -124,7 +124,7 @@ public class ClanEntryManager
_log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage()); _log.warning(getClass().getSimpleName() + ": Exception: ClanEntryManager.load(): " + e.getMessage());
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId")) ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId"))
{ {
@ -170,7 +170,7 @@ public class ClanEntryManager
{ {
final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId); final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId);
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT)) PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT))
{ {
statement.setInt(1, playerId); statement.setInt(1, playerId);
@ -191,7 +191,7 @@ public class ClanEntryManager
{ {
_applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info); _applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info);
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT)) PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT))
{ {
statement.setInt(1, info.getPlayerId()); statement.setInt(1, info.getPlayerId());
@ -218,7 +218,7 @@ public class ClanEntryManager
{ {
if (!_playerLocked.containsKey(playerId)) if (!_playerLocked.containsKey(playerId))
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST)) PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST))
{ {
statement.setInt(1, info.getPlayerId()); statement.setInt(1, info.getPlayerId());
@ -239,7 +239,7 @@ public class ClanEntryManager
{ {
if (_waitingList.containsKey(playerId)) if (_waitingList.containsKey(playerId))
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST)) PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST))
{ {
statement.setInt(1, playerId); statement.setInt(1, playerId);
@ -260,7 +260,7 @@ public class ClanEntryManager
{ {
if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId)) if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_CLAN_RECRUIT)) PreparedStatement statement = con.prepareStatement(INSERT_CLAN_RECRUIT))
{ {
statement.setInt(1, info.getClanId()); statement.setInt(1, info.getClanId());
@ -282,7 +282,7 @@ public class ClanEntryManager
{ {
if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId)) if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CLAN_RECRUIT)) PreparedStatement statement = con.prepareStatement(UPDATE_CLAN_RECRUIT))
{ {
statement.setInt(1, info.getKarma()); statement.setInt(1, info.getKarma());
@ -304,7 +304,7 @@ public class ClanEntryManager
{ {
if (_clanList.containsKey(clanId)) if (_clanList.containsKey(clanId))
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_CLAN_RECRUIT)) PreparedStatement statement = con.prepareStatement(DELETE_CLAN_RECRUIT))
{ {
statement.setInt(1, clanId); statement.setInt(1, clanId);

View File

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

View File

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

View File

@ -36,7 +36,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.enums.ItemLocation; import com.l2jserver.gameserver.enums.ItemLocation;
import com.l2jserver.gameserver.enums.MailType; import com.l2jserver.gameserver.enums.MailType;
@ -81,7 +81,7 @@ public final class CommissionManager
protected CommissionManager() protected CommissionManager()
{ {
final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>(); final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS)) try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS))
{ {
@ -255,7 +255,7 @@ public final class CommissionManager
return; return;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS)) PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS))
{ {
final Instant startTime = Instant.now(); final Instant startTime = Instant.now();
@ -408,7 +408,7 @@ public final class CommissionManager
*/ */
private boolean deleteItemFromDB(long commissionId) private boolean deleteItemFromDB(long commissionId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM)) PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM))
{ {
ps.setLong(1, commissionId); ps.setLong(1, commissionId);

View File

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

View File

@ -38,7 +38,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.CursedWeapon; import com.l2jserver.gameserver.model.CursedWeapon;
import com.l2jserver.gameserver.model.actor.L2Attackable; import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Character;
@ -172,7 +172,7 @@ public final class CursedWeaponsManager
private final void restore() private final void restore()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT itemId, charId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons")) ResultSet rs = s.executeQuery("SELECT itemId, charId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons"))
{ {
@ -197,15 +197,17 @@ public final class CursedWeaponsManager
private final void controlPlayers() private final void controlPlayers()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); // TODO: See comments below...
// This entire for loop should NOT be necessary, since it is already handled by
// CursedWeapon.endOfLife(). However, if we indeed *need* to duplicate it for safety,
// then we'd better make sure that it FULLY cleans up inactive cursed weapons!
// Undesired effects result otherwise, such as player with no zariche but with karma
// or a lost-child entry in the cursed weapons table, without a corresponding one in items...
// Retrieve the L2PcInstance from the characters table of the database
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?")) PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
{ {
// TODO: See comments below...
// This entire for loop should NOT be necessary, since it is already handled by
// CursedWeapon.endOfLife(). However, if we indeed *need* to duplicate it for safety,
// then we'd better make sure that it FULLY cleans up inactive cursed weapons!
// Undesired effects result otherwise, such as player with no zariche but with karma
// or a lost-child entry in the cursed weapons table, without a corresponding one in items...
for (CursedWeapon cw : _cursedWeapons.values()) for (CursedWeapon cw : _cursedWeapons.values())
{ {
if (cw.isActivated()) if (cw.isActivated())
@ -250,6 +252,7 @@ public final class CursedWeaponsManager
removeFromDb(itemId); removeFromDb(itemId);
} }
} }
ps.clearParameters();
} }
} }
catch (Exception e) catch (Exception e)
@ -368,7 +371,7 @@ public final class CursedWeaponsManager
public static void removeFromDb(int itemId) public static void removeFromDb(int itemId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?"))
{ {
ps.setInt(1, itemId); ps.setInt(1, itemId);

View File

@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/** /**
@ -48,7 +48,7 @@ public class FactionManager
private void loadAll() private void loadAll()
{ {
_playerFactions.clear(); _playerFactions.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters")) ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
{ {
@ -78,7 +78,7 @@ public class FactionManager
return factionId; return factionId;
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?")) PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
{ {
ps.setInt(1, id); ps.setInt(1, id);

View File

@ -29,7 +29,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.ItemTable; import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance; import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
@ -101,7 +101,7 @@ public class FishingChampionshipManager
{ {
_enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0); _enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0);
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement(SELECT); PreparedStatement statement = con.prepareStatement(SELECT);
ResultSet rs = statement.executeQuery(); ResultSet rs = statement.executeQuery();
@ -375,7 +375,7 @@ public class FishingChampionshipManager
{ {
GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate); GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate);
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement(DELETE); PreparedStatement statement = con.prepareStatement(DELETE);
statement.execute(); statement.execute();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.L2Mentee; import com.l2jserver.gameserver.model.L2Mentee;
import com.l2jserver.gameserver.model.L2World; import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -56,7 +56,7 @@ public class MentorManager
private void load() private void load()
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees")) ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees"))
{ {
@ -78,7 +78,7 @@ public class MentorManager
*/ */
public void deleteMentee(int mentorId, int menteeId) public void deleteMentee(int mentorId, int menteeId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
{ {
statement.setInt(1, mentorId); statement.setInt(1, mentorId);
@ -97,7 +97,7 @@ public class MentorManager
*/ */
public void deleteMentor(int mentorId, int menteeId) public void deleteMentor(int mentorId, int menteeId)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
{ {
statement.setInt(1, mentorId); statement.setInt(1, mentorId);

View File

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

View File

@ -25,7 +25,7 @@ import java.sql.SQLException;
import java.util.Calendar; import java.util.Calendar;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory; import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.L2World; import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -38,7 +38,7 @@ public class PremiumManager
public long getPremiumEndDate(String accountName) public long getPremiumEndDate(String accountName)
{ {
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement("SELECT premium_service,enddate FROM account_premium WHERE account_name=?"); PreparedStatement statement = con.prepareStatement("SELECT premium_service,enddate FROM account_premium WHERE account_name=?");
statement.setString(1, accountName); statement.setString(1, accountName);
@ -72,7 +72,7 @@ public class PremiumManager
remainingTime -= System.currentTimeMillis(); remainingTime -= System.currentTimeMillis();
} }
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
Calendar endDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance();
endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime); endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime);
@ -102,7 +102,7 @@ public class PremiumManager
public void removePremiumStatus(String accountName) public void removePremiumStatus(String accountName)
{ {
// TODO: Add check if account exists. XD // TODO: Add check if account exists. XD
try (Connection con = L2DatabaseFactory.getInstance().getConnection()) try (Connection con = ConnectionFactory.getInstance().getConnection())
{ {
PreparedStatement statement = con.prepareStatement("INSERT INTO account_premium (account_name,premium_service,enddate) values(?,?,?) ON DUPLICATE KEY UPDATE premium_service = ?, enddate = ?"); PreparedStatement statement = con.prepareStatement("INSERT INTO account_premium (account_name,premium_service,enddate) values(?,?,?) ON DUPLICATE KEY UPDATE premium_service = ?, enddate = ?");
statement.setString(1, accountName); statement.setString(1, accountName);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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