Dropped c3p0 in favor of HikariCP.

This commit is contained in:
MobiusDev
2018-09-08 19:27:23 +00:00
parent 6fd681adcf
commit eb3742d44f
1149 changed files with 3883 additions and 4317 deletions

View File

@@ -5,11 +5,12 @@
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/> <classpathentry kind="lib" path="dist/libs/HikariCP-3.2.0.jar"/>
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/> <classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/> <classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/> <classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
<classpathentry kind="lib" path="dist/libs/slf4j-api-1.7.25.jar"/>
<classpathentry kind="lib" path="dist/libs/slf4j-simple-1.7.25.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="output" path="bin"/> <classpathentry kind="output" path="bin"/>

View File

@@ -76,7 +76,7 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
} }
else else
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"); final PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
statement.setInt(1, lvl); statement.setInt(1, lvl);

View File

@@ -631,7 +631,7 @@ public class AdminEditChar implements IAdminCommandHandler
if (player == null) if (player == null)
{ {
final Connection con = DatabaseFactory.getInstance().getConnection(); final Connection con = DatabaseFactory.getConnection();
final PreparedStatement ps = con.prepareStatement("UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1"); final PreparedStatement ps = con.prepareStatement("UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1");
ps.setString(1, playerName); ps.setString(1, playerName);

View File

@@ -62,7 +62,7 @@ public class AdminRepairChar implements IAdminCommandHandler
} }
final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?"; final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
PreparedStatement statement = con.prepareStatement(cmd); PreparedStatement statement = con.prepareStatement(cmd);
statement.setString(1, parts[1]); statement.setString(1, parts[1]);
@@ -87,13 +87,13 @@ public class AdminRepairChar implements IAdminCommandHandler
return; return;
} }
// connection = L2DatabaseFactory.getInstance().getConnection(); // connection = L2DatabaseFactory.getConnection();
statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?"); statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
statement.setInt(1, objId); statement.setInt(1, objId);
statement.execute(); statement.execute();
statement.close(); statement.close();
// connection = L2DatabaseFactory.getInstance().getConnection(); // connection = L2DatabaseFactory.getConnection();
statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?"); statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
statement.setInt(1, objId); statement.setInt(1, objId);
statement.execute(); statement.execute();

View File

@@ -173,7 +173,7 @@ public class AdminShowQuests implements IAdminCommandHandler
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val) private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
ResultSet rs; ResultSet rs;
PreparedStatement req; PreparedStatement req;

View File

@@ -489,7 +489,7 @@ public class AdminTeleport implements IAdminCommandHandler
final int x = activeChar.getX(); final int x = activeChar.getX();
final int y = activeChar.getY(); final int y = activeChar.getY();
final int z = activeChar.getZ(); final int z = activeChar.getZ();
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"); final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
statement.setInt(1, x); statement.setInt(1, x);

View File

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

@@ -300,7 +300,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -62,7 +62,7 @@ public class ClanWarsList implements IUserCommandHandler
return false; return false;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
String query; String query;
// Attack List // Attack List

View File

@@ -1 +1 @@
-server -Dfile.encoding=UTF-8 -Djava.util.logging.manager=com.l2jmobius.log.L2LogManager -XX:+AggressiveOpts -Xnoclassgc -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -Xmx4g -Xms2g -Xmn1g -server -Dfile.encoding=UTF-8 -Djava.util.logging.manager=com.l2jmobius.log.L2LogManager -Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=error -XX:+AggressiveOpts -Xnoclassgc -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -Xmx4g -Xms2g -Xmn1g

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
-server -Xms128m -Xmx256m -server -Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=error -Xms128m -Xmx256m

View File

@@ -16,122 +16,68 @@
*/ */
package com.l2jmobius.commons.database; package com.l2jmobius.commons.database;
import java.beans.PropertyVetoException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.mchange.v2.c3p0.ComboPooledDataSource; import com.zaxxer.hikari.HikariDataSource;
/** /**
* Database Factory implementation. * @author Mobius
* @author Zoey76, Mobius
*/ */
public class DatabaseFactory public class DatabaseFactory
{ {
private static final Logger LOGGER = Logger.getLogger(DatabaseFactory.class.getName()); private static final Logger LOGGER = Logger.getLogger(DatabaseFactory.class.getName());
private final ComboPooledDataSource _dataSource; private static final HikariDataSource _hds = new HikariDataSource();
public DatabaseFactory() public static void init()
{ {
if (Config.DATABASE_MAX_CONNECTIONS < 2) _hds.setDriverClassName(Config.DATABASE_DRIVER);
{ _hds.setJdbcUrl(Config.DATABASE_URL);
Config.DATABASE_MAX_CONNECTIONS = 2; _hds.setUsername(Config.DATABASE_LOGIN);
LOGGER.warning("A minimum of 2 connections are required."); _hds.setPassword(Config.DATABASE_PASSWORD);
} _hds.setMaximumPoolSize(Config.DATABASE_MAX_CONNECTIONS);
_hds.setIdleTimeout(Config.DATABASE_MAX_IDLE_TIME);
_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
// Test if connection is valid.
try try
{ {
_dataSource.setDriverClass(Config.DATABASE_DRIVER); _hds.getConnection().close();
LOGGER.info("Database: Initialized.");
} }
catch (PropertyVetoException e) catch (Exception e)
{ {
e.printStackTrace(); 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)
{
e.printStackTrace();
}
LOGGER.info("Database: Initialized.");
} }
public Connection getConnection() public static Connection getConnection()
{ {
Connection con = null; Connection con = null;
while (con == null) while (con == null)
{ {
try try
{ {
con = _dataSource.getConnection(); con = _hds.getConnection();
} }
catch (SQLException e) catch (Exception e)
{ {
LOGGER.warning(getClass().getSimpleName() + ": Unable to get a connection: " + e.getMessage()); LOGGER.severe("DatabaseFactory: Cound not get a connection. " + e);
} }
} }
return con; return con;
} }
public void close() public static void close()
{ {
try try
{ {
_dataSource.close(); _hds.close();
} }
catch (Exception e) catch (Exception e)
{ {
LOGGER.info(e.getMessage()); LOGGER.severe("DatabaseFactory: There was a problem closing the data source. " + e);
} }
} }
public static DatabaseFactory getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DatabaseFactory INSTANCE = new DatabaseFactory();
}
} }

View File

@@ -192,7 +192,7 @@ public class GameServer
// Initialize config // Initialize config
Config.load(); Config.load();
printSection("Database"); printSection("Database");
DatabaseFactory.getInstance(); DatabaseFactory.init();
printSection("ThreadPool"); printSection("ThreadPool");
ThreadPool.init(); ThreadPool.init();

View File

@@ -584,7 +584,7 @@ public class LoginServerThread extends Thread
int chars = 0; int chars = 0;
final List<Long> charToDel = new ArrayList<>(); final List<Long> charToDel = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -204,7 +204,7 @@ public class Shutdown extends Thread
// commit data, last chance // commit data, last chance
try try
{ {
DatabaseFactory.getInstance().close(); DatabaseFactory.close();
LOGGER.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms)."); LOGGER.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
} }
catch (Throwable t) catch (Throwable t)

View File

@@ -93,7 +93,7 @@ public class Forum
private void load() private void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
LOGGER.log(Level.WARNING, "Data error on Forum " + _forumId + " : " + e.getMessage(), e); LOGGER.log(Level.WARNING, "Data error on Forum " + _forumId + " : " + e.getMessage(), e);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -217,7 +217,7 @@ public class Forum
public void insertIntoDb() public void insertIntoDb()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -72,7 +72,7 @@ public class Post
private void insertindb(CPost cp) private void insertindb(CPost cp)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -112,7 +112,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -130,7 +130,7 @@ public class Post
*/ */
private void load(Topic t) private void load(Topic t)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -162,7 +162,7 @@ public class Post
*/ */
public void updatetxt(int i) public void updatetxt(int i)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
{ {
final CPost cp = getCPost(i); final CPost cp = getCPost(i);

View File

@@ -71,7 +71,7 @@ public class Topic
private void insertindb() private void insertindb()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
{ {
ps.setInt(1, _id); ps.setInt(1, _id);
@@ -129,7 +129,7 @@ public class Topic
{ {
TopicBBSManager.getInstance().delTopic(this); TopicBBSManager.getInstance().delTopic(this);
f.rmTopicByID(_id); f.rmTopicByID(_id);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _id); ps.setInt(1, _id);

View File

@@ -40,7 +40,7 @@ public class ForumsBBSManager extends BaseBBSManager
protected ForumsBBSManager() protected ForumsBBSManager()
{ {
_table = new CopyOnWriteArrayList<>(); _table = new CopyOnWriteArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -52,7 +52,7 @@ public final class AnnouncementsTable
private void load() private void load()
{ {
_announcements.clear(); _announcements.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -99,7 +99,7 @@ public class CharNameTable
int id = -1; int id = -1;
int accessLevel = 0; int accessLevel = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?")) PreparedStatement ps = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?"))
{ {
ps.setString(1, name); ps.setString(1, name);
@@ -145,7 +145,7 @@ public class CharNameTable
return null; return null;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -176,7 +176,7 @@ public class CharNameTable
public synchronized boolean doesCharNameExist(String name) public synchronized boolean doesCharNameExist(String name)
{ {
boolean result = false; boolean result = false;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) as count FROM characters WHERE char_name=?")) PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) as count FROM characters WHERE char_name=?"))
{ {
ps.setString(1, name); ps.setString(1, name);
@@ -197,7 +197,7 @@ public class CharNameTable
public int getAccountCharacterCount(String account) public int getAccountCharacterCount(String account)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT COUNT(char_name) as count FROM characters WHERE account_name=?")) PreparedStatement ps = con.prepareStatement("SELECT COUNT(char_name) as count FROM characters WHERE account_name=?"))
{ {
ps.setString(1, account); ps.setString(1, account);
@@ -218,7 +218,7 @@ public class CharNameTable
public int getLevelById(int objectId) public int getLevelById(int objectId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -239,7 +239,7 @@ public class CharNameTable
public int getClassIdById(int objectId) public int getClassIdById(int objectId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -260,7 +260,7 @@ public class CharNameTable
public int getClanIdById(int objectId) public int getClanIdById(int objectId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clanId FROM characters WHERE charId = ?")) PreparedStatement ps = con.prepareStatement("SELECT clanId FROM characters WHERE charId = ?"))
{ {
ps.setInt(1, objectId); ps.setInt(1, objectId);
@@ -281,7 +281,7 @@ public class CharNameTable
private void loadAll() private void loadAll()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -70,7 +70,7 @@ public class CharSummonTable
{ {
if (Config.RESTORE_SERVITOR_ON_RECONNECT) if (Config.RESTORE_SERVITOR_ON_RECONNECT)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_SUMMONS)) ResultSet rs = s.executeQuery(INIT_SUMMONS))
{ {
@@ -87,7 +87,7 @@ public class CharSummonTable
if (Config.RESTORE_PET_ON_RECONNECT) if (Config.RESTORE_PET_ON_RECONNECT)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_PET)) ResultSet rs = s.executeQuery(INIT_PET))
{ {
@@ -111,7 +111,7 @@ public class CharSummonTable
return !v.isEmpty() ? v : null; return !v.isEmpty() ? v : null;
}); });
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON)) PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
{ {
ps.setInt(1, activeChar.getObjectId()); ps.setInt(1, activeChar.getObjectId());
@@ -181,7 +181,7 @@ public class CharSummonTable
public void restoreServitor(L2PcInstance activeChar) public void restoreServitor(L2PcInstance activeChar)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -79,7 +79,7 @@ public class ClanTable
L2Clan clan; L2Clan clan;
// Count the clans // Count the clans
int clanCount = 0; int clanCount = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -258,7 +258,7 @@ public class ClanTable
_clans.remove(clanId); _clans.remove(clanId);
IdFactory.getInstance().releaseId(clanId); IdFactory.getInstance().releaseId(clanId);
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.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=?"))
{ {
@@ -357,7 +357,7 @@ public class ClanTable
public void storeclanswars(ClanWar war) public void storeclanswars(ClanWar war)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, clan1Kill, clan2Kill, winnerClan, startTime, endTime, state) VALUES(?,?,?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, clan1Kill, clan2Kill, winnerClan, startTime, endTime, state) VALUES(?,?,?,?,?,?,?,?)"))
{ {
ps.setInt(1, war.getAttackerClanId()); ps.setInt(1, war.getAttackerClanId());
@@ -388,7 +388,7 @@ public class ClanTable
clan1.broadcastClanStatus(); clan1.broadcastClanStatus();
clan2.broadcastClanStatus(); clan2.broadcastClanStatus();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -403,7 +403,7 @@ public class ClanTable
private void restorewars() private void restorewars()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT clan1, clan2, clan1Kill, clan2Kill, winnerClan, startTime, endTime, state FROM clan_wars")) ResultSet rset = statement.executeQuery("SELECT clan1, clan2, clan1Kill, clan2Kill, winnerClan, startTime, endTime, state FROM clan_wars"))
{ {

View File

@@ -72,7 +72,7 @@ public final class CrestTable
} }
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -154,7 +154,7 @@ public final class CrestTable
*/ */
public L2Crest createCrest(byte[] data, CrestType crestType) public L2Crest createCrest(byte[] data, CrestType crestType)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
{ {
final L2Crest crest = new L2Crest(_nextId.getAndIncrement(), data, crestType); final L2Crest crest = new L2Crest(_nextId.getAndIncrement(), data, crestType);
@@ -187,7 +187,7 @@ public final class CrestTable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -56,7 +56,7 @@ public class OfflineTradersTable
public void storeOffliners() public void storeOffliners()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -173,7 +173,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement stm = con.createStatement(); Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS)) ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS))
{ {
@@ -329,7 +329,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -453,7 +453,7 @@ public class OfflineTradersTable
{ {
PlayerCountManager.getInstance().decOfflineTradeCount(); PlayerCountManager.getInstance().decOfflineTradeCount();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {

View File

@@ -42,7 +42,7 @@ public class PetNameTable
public boolean doesPetNameExist(String name, int petNpcId) public boolean doesPetNameExist(String name, int petNpcId)
{ {
boolean result = true; boolean result = true;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -66,7 +66,7 @@ public final class BuyListData implements IGameXmlReader
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _buyLists.size() + " BuyLists."); LOGGER.info(getClass().getSimpleName() + ": Loaded " + _buyLists.size() + " BuyLists.");
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -112,7 +112,7 @@ public final class BotReportTable
*/ */
private void loadReportedCharData() private void loadReportedCharData()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -386,7 +386,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -128,7 +128,7 @@ public abstract class IdFactory
*/ */
private void setAllCharacterOffline() private void setAllCharacterOffline()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
s.executeUpdate("UPDATE characters SET online = 0"); s.executeUpdate("UPDATE characters SET online = 0");
@@ -145,7 +145,7 @@ public abstract class IdFactory
*/ */
private void cleanUpDB() private void cleanUpDB()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement stmt = con.createStatement()) Statement stmt = con.createStatement())
{ {
final long cleanupStart = System.currentTimeMillis(); final long cleanupStart = System.currentTimeMillis();
@@ -253,7 +253,7 @@ public abstract class IdFactory
private void cleanUpTimeStamps() private void cleanUpTimeStamps()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
int cleanCount = 0; int cleanCount = 0;
for (String line : TIMESTAMPS_CLEAN) for (String line : TIMESTAMPS_CLEAN)
@@ -279,7 +279,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
String extractUsedObjectIdsQuery = ""; String extractUsedObjectIdsQuery = "";

View File

@@ -42,7 +42,7 @@ public class StackIDFactory extends IdFactory
_curOID = FIRST_OID; _curOID = FIRST_OID;
_tempOID = FIRST_OID; _tempOID = FIRST_OID;
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// con.createStatement().execute("drop table if exists tmp_obj_id"); // con.createStatement().execute("drop table if exists tmp_obj_id");

View File

@@ -169,7 +169,7 @@ public class AirShipManager
_airShipsInfo.put(ownerId, info); _airShipsInfo.put(ownerId, info);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(ADD_DB)) PreparedStatement ps = con.prepareStatement(ADD_DB))
{ {
ps.setInt(1, ownerId); ps.setInt(1, ownerId);
@@ -265,7 +265,7 @@ public class AirShipManager
private void load() private void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery(LOAD_DB)) ResultSet rs = s.executeQuery(LOAD_DB))
{ {
@@ -296,7 +296,7 @@ public class AirShipManager
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -198,7 +198,7 @@ public final class CastleManager implements InstanceListManager
} }
} }
// else offline-player circlet removal // else offline-player circlet removal
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -215,7 +215,7 @@ public final class CastleManager implements InstanceListManager
@Override @Override
public void loadInstances() public void loadInstances()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -162,7 +162,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
private void loadDb() private void loadDb()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
{ {
@@ -436,7 +436,7 @@ public final class CastleManorManager implements IGameXmlReader, 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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -472,7 +472,7 @@ public final class CastleManorManager implements IGameXmlReader, 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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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))
{ {
@@ -506,7 +506,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
public final void updateCurrentProduction(int castleId, Collection<SeedProduction> items) public final void updateCurrentProduction(int castleId, Collection<SeedProduction> items)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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)
@@ -526,7 +526,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
public final void updateCurrentProcure(int castleId, Collection<CropProcure> items) public final void updateCurrentProcure(int castleId, Collection<CropProcure> items)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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)
@@ -599,7 +599,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
@Override @Override
public final boolean storeMe() public final boolean storeMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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");
@@ -697,7 +697,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS) if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -91,7 +91,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MARKS, 0); GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MARKS, 0);
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MEMBER, 0); GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MEMBER, 0);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
{ {
ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_MARKS); ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_MARKS);
@@ -102,7 +102,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
LOGGER.severe(getClass().getSimpleName() + ": Could not reset Ceremony Of Chaos victories: " + e); LOGGER.severe(getClass().getSimpleName() + ": Could not reset Ceremony Of Chaos victories: " + e);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
{ {
ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_PROHIBITED_PENALTIES); ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_PROHIBITED_PENALTIES);

View File

@@ -91,7 +91,7 @@ public class ClanEntryManager
private void load() private void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit")) ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit"))
{ {
@@ -106,7 +106,7 @@ public class ClanEntryManager
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Failed to load: ", e); LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Failed to load: ", e);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId")) ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId"))
{ {
@@ -122,7 +122,7 @@ public class ClanEntryManager
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Failed to load: ", e); LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Failed to load: ", e);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId")) ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId"))
{ {
@@ -168,7 +168,7 @@ public class ClanEntryManager
{ {
final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId); final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT)) PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT))
{ {
statement.setInt(1, playerId); statement.setInt(1, playerId);
@@ -189,7 +189,7 @@ public class ClanEntryManager
{ {
_applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info); _applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT)) PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT))
{ {
statement.setInt(1, info.getPlayerId()); statement.setInt(1, info.getPlayerId());
@@ -216,7 +216,7 @@ public class ClanEntryManager
{ {
if (!_playerLocked.containsKey(playerId)) if (!_playerLocked.containsKey(playerId))
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST)) PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST))
{ {
statement.setInt(1, info.getPlayerId()); statement.setInt(1, info.getPlayerId());
@@ -237,7 +237,7 @@ public class ClanEntryManager
{ {
if (_waitingList.containsKey(playerId)) if (_waitingList.containsKey(playerId))
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST)) PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST))
{ {
statement.setInt(1, playerId); statement.setInt(1, playerId);
@@ -258,7 +258,7 @@ public class ClanEntryManager
{ {
if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId)) if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -283,7 +283,7 @@ public class ClanEntryManager
{ {
if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId)) if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -307,7 +307,7 @@ public class ClanEntryManager
{ {
if (_clanList.containsKey(clanId)) if (_clanList.containsKey(clanId))
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -79,7 +79,7 @@ public final class CommissionManager
protected CommissionManager() protected CommissionManager()
{ {
final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>(); final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS)) try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS))
{ {
@@ -245,7 +245,7 @@ public final class CommissionManager
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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();
@@ -398,7 +398,7 @@ public final class CommissionManager
*/ */
private boolean deleteItemFromDB(long commissionId) private boolean deleteItemFromDB(long commissionId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -142,7 +142,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
private void restore() private void restore()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement(); Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT itemId, charId, playerReputation, playerPkKills, nbKills, endTime FROM cursed_weapons")) ResultSet rs = s.executeQuery("SELECT itemId, charId, playerReputation, playerPkKills, nbKills, endTime FROM cursed_weapons"))
{ {
@@ -167,7 +167,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
private void controlPlayers() private void controlPlayers()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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... // TODO: See comments below...
@@ -338,7 +338,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
public static void removeFromDb(int itemId) public static void removeFromDb(int itemId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -85,7 +85,7 @@ public class DBSpawnManager
_storedInfo.clear(); _storedInfo.clear();
_schedules.clear(); _schedules.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM npc_respawns"); PreparedStatement statement = con.prepareStatement("SELECT * FROM npc_respawns");
ResultSet rset = statement.executeQuery()) ResultSet rset = statement.executeQuery())
{ {
@@ -275,7 +275,7 @@ public class DBSpawnManager
if (storeInDb) if (storeInDb)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO npc_respawns (id, x, y, z, heading, respawnTime, currentHp, currentMp) VALUES(?, ?, ?, ?, ?, ?, ?, ?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO npc_respawns (id, x, y, z, heading, respawnTime, currentHp, currentMp) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"))
{ {
statement.setInt(1, spawn.getId()); statement.setInt(1, spawn.getId());
@@ -331,7 +331,7 @@ public class DBSpawnManager
if (storeInDb) if (storeInDb)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO npc_respawns (id, x, y, z, heading, respawnTime, currentHp, currentMp) VALUES(?, ?, ?, ?, ?, ?, ?, ?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO npc_respawns (id, x, y, z, heading, respawnTime, currentHp, currentMp) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"))
{ {
statement.setInt(1, spawn.getId()); statement.setInt(1, spawn.getId());
@@ -380,7 +380,7 @@ public class DBSpawnManager
if (updateDb) if (updateDb)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM npc_respawns WHERE id = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM npc_respawns WHERE id = ?"))
{ {
ps.setInt(1, npcId); ps.setInt(1, npcId);
@@ -401,7 +401,7 @@ public class DBSpawnManager
*/ */
private void updateDb() private void updateDb()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE npc_respawns SET respawnTime = ?, currentHP = ?, currentMP = ? WHERE id = ?")) PreparedStatement statement = con.prepareStatement("UPDATE npc_respawns SET respawnTime = ?, currentHP = ?, currentMP = ? WHERE id = ?"))
{ {
for (Integer npcId : _storedInfo.keySet()) for (Integer npcId : _storedInfo.keySet())

View File

@@ -117,7 +117,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
} }
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
try (PreparedStatement st = con.prepareStatement("UPDATE character_subclasses SET vitality_points = ?")) try (PreparedStatement st = con.prepareStatement("UPDATE character_subclasses SET vitality_points = ?"))
{ {
@@ -147,7 +147,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
private void resetExtendDrop() private void resetExtendDrop()
{ {
// Update data for offline players. // Update data for offline players.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
{ {
ps.setString(1, PlayerVariables.EXTEND_DROP); ps.setString(1, PlayerVariables.EXTEND_DROP);
@@ -170,7 +170,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
private void resetDailySkills() private void resetDailySkills()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
final List<SkillHolder> dailySkills = getVariables().getList("reset_skills", SkillHolder.class, Collections.emptyList()); final List<SkillHolder> dailySkills = getVariables().getList("reset_skills", SkillHolder.class, Collections.emptyList());
for (SkillHolder skill : dailySkills) for (SkillHolder skill : dailySkills)
@@ -197,7 +197,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
} }
// Update data for offline players. // Update data for offline players.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE character_variables SET val = ? WHERE var = ?")) PreparedStatement ps = con.prepareStatement("UPDATE character_variables SET val = ? WHERE var = ?"))
{ {
ps.setInt(1, 0); ps.setInt(1, 0);
@@ -222,7 +222,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
private void resetRecommends() private void resetRecommends()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement("UPDATE character_reco_bonus SET rec_left = ?, rec_have = 0 WHERE rec_have <= 20")) try (PreparedStatement ps = con.prepareStatement("UPDATE character_reco_bonus SET rec_left = ?, rec_have = 0 WHERE rec_have <= 20"))
{ {
@@ -255,7 +255,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
if (Config.TRAINING_CAMP_ENABLE) if (Config.TRAINING_CAMP_ENABLE)
{ {
// Update data for offline players. // Update data for offline players.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM account_gsdata WHERE var = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM account_gsdata WHERE var = ?"))
{ {
ps.setString(1, "TRAINING_CAMP_DURATION"); ps.setString(1, "TRAINING_CAMP_DURATION");

View File

@@ -46,7 +46,7 @@ public class FactionManager
private void loadAll() private void loadAll()
{ {
_playerFactions.clear(); _playerFactions.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -75,7 +75,7 @@ public class FactionManager
return factionId; return factionId;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -121,7 +121,7 @@ public final class FortManager implements InstanceListManager
@Override @Override
public void loadInstances() public void loadInstances()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -86,7 +86,7 @@ public final class FortSiegeManager
} }
boolean register = false; boolean register = false;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -56,7 +56,7 @@ public final class GlobalVariablesManager extends AbstractVariables
public boolean restoreMe() public boolean restoreMe()
{ {
// Restore previous variables. // Restore previous variables.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement st = con.createStatement(); Statement st = con.createStatement();
ResultSet rset = st.executeQuery(SELECT_QUERY)) ResultSet rset = st.executeQuery(SELECT_QUERY))
{ {
@@ -87,7 +87,7 @@ public final class GlobalVariablesManager extends AbstractVariables
return false; return false;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement del = con.createStatement(); Statement del = con.createStatement();
PreparedStatement st = con.prepareStatement(INSERT_QUERY)) PreparedStatement st = con.prepareStatement(INSERT_QUERY))
{ {
@@ -119,7 +119,7 @@ public final class GlobalVariablesManager extends AbstractVariables
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement del = con.createStatement()) Statement del = con.createStatement())
{ {
del.execute(DELETE_QUERY); del.execute(DELETE_QUERY);

View File

@@ -62,7 +62,7 @@ public final class GrandBossManager implements IStorable
private void init() private void init()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -150,7 +150,7 @@ public final class GrandBossManager implements IStorable
@Override @Override
public boolean storeMe() public boolean storeMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
for (Entry<Integer, StatsSet> e : _storedInfo.entrySet()) for (Entry<Integer, StatsSet> e : _storedInfo.entrySet())
{ {
@@ -202,7 +202,7 @@ public final class GrandBossManager implements IStorable
private void updateDb(int bossId, boolean statusOnly) private void updateDb(int bossId, boolean statusOnly)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
final L2GrandBossInstance boss = _bosses.get(bossId); final L2GrandBossInstance boss = _bosses.get(bossId);
final StatsSet info = _storedInfo.get(bossId); final StatsSet info = _storedInfo.get(bossId);

View File

@@ -498,7 +498,7 @@ public final class InstanceManager implements IGameXmlReader
*/ */
private void restoreInstanceTimes() private void restoreInstanceTimes()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement ps = con.createStatement(); Statement ps = con.createStatement();
ResultSet rs = ps.executeQuery("SELECT * FROM character_instance_time ORDER BY charId")) ResultSet rs = ps.executeQuery("SELECT * FROM character_instance_time ORDER BY charId"))
{ {
@@ -550,7 +550,7 @@ public final class InstanceManager implements IGameXmlReader
// Remove them // Remove them
if (!invalidPenalty.isEmpty()) if (!invalidPenalty.isEmpty())
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME)) PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
{ {
for (Integer id : invalidPenalty) for (Integer id : invalidPenalty)
@@ -615,7 +615,7 @@ public final class InstanceManager implements IGameXmlReader
*/ */
public void deleteInstanceTime(L2PcInstance player, int id) public void deleteInstanceTime(L2PcInstance player, int id)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME)) PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
{ {
ps.setInt(1, player.getObjectId()); ps.setInt(1, player.getObjectId());

View File

@@ -55,7 +55,7 @@ public final class ItemAuctionManager implements IGameXmlReader
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1")) ResultSet rset = statement.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1"))
{ {
@@ -134,7 +134,7 @@ public final class ItemAuctionManager implements IGameXmlReader
public static void deleteAuction(int auctionId) public static void deleteAuction(int auctionId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
try (PreparedStatement statement = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?")) try (PreparedStatement statement = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?"))
{ {

View File

@@ -80,7 +80,7 @@ public final class ItemsOnGroundManager implements Runnable
str = "UPDATE itemsonground SET drop_time = ? WHERE drop_time = -1"; str = "UPDATE itemsonground SET drop_time = ? WHERE drop_time = -1";
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(str)) PreparedStatement ps = con.prepareStatement(str))
{ {
ps.setLong(1, System.currentTimeMillis()); ps.setLong(1, System.currentTimeMillis());
@@ -93,7 +93,7 @@ public final class ItemsOnGroundManager implements Runnable
} }
// Add items to world // Add items to world
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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;
@@ -178,7 +178,7 @@ public final class ItemsOnGroundManager implements Runnable
public void emptyTable() public void emptyTable()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement()) Statement s = con.createStatement())
{ {
s.executeUpdate("DELETE FROM itemsonground"); s.executeUpdate("DELETE FROM itemsonground");
@@ -204,7 +204,7 @@ public final class ItemsOnGroundManager implements Runnable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)")) PreparedStatement statement = 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)

View File

@@ -57,7 +57,7 @@ public final class MailManager
private void load() private void load()
{ {
int count = 0; int count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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"))
{ {
@@ -192,7 +192,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = Message.getStatement(msg, con)) PreparedStatement ps = Message.getStatement(msg, con))
{ {
ps.execute(); ps.execute();
@@ -214,7 +214,7 @@ public final class MailManager
public final void markAsReadInDb(int msgId) public final void markAsReadInDb(int msgId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -228,7 +228,7 @@ public final class MailManager
public final void markAsDeletedBySenderInDb(int msgId) public final void markAsDeletedBySenderInDb(int msgId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -242,7 +242,7 @@ public final class MailManager
public final void markAsDeletedByReceiverInDb(int msgId) public final void markAsDeletedByReceiverInDb(int msgId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -256,7 +256,7 @@ public final class MailManager
public final void removeAttachmentsInDb(int msgId) public final void removeAttachmentsInDb(int msgId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -270,7 +270,7 @@ public final class MailManager
public final void deleteMessageInDb(int msgId) public final void deleteMessageInDb(int msgId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -54,7 +54,7 @@ public class MentorManager
private void load() private void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement(); Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees")) ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees"))
{ {
@@ -76,7 +76,7 @@ public class MentorManager
*/ */
public void deleteMentee(int mentorId, int menteeId) public void deleteMentee(int mentorId, int menteeId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
{ {
statement.setInt(1, mentorId); statement.setInt(1, mentorId);
@@ -95,7 +95,7 @@ public class MentorManager
*/ */
public void deleteMentor(int mentorId, int menteeId) public void deleteMentor(int mentorId, int menteeId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -128,7 +128,7 @@ public class PremiumManager
private void loadPremiumData(String accountName) private void loadPremiumData(String accountName)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stmt = con.prepareStatement(LOAD_SQL)) PreparedStatement stmt = con.prepareStatement(LOAD_SQL))
{ {
stmt.setString(1, accountName); stmt.setString(1, accountName);
@@ -160,7 +160,7 @@ public class PremiumManager
long newPremiumExpiration = oldPremiumExpiration + addTime; long newPremiumExpiration = oldPremiumExpiration + addTime;
// UPDATE DATABASE // UPDATE DATABASE
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stmt = con.prepareStatement(UPDATE_SQL)) PreparedStatement stmt = con.prepareStatement(UPDATE_SQL))
{ {
stmt.setLong(1, newPremiumExpiration); stmt.setLong(1, newPremiumExpiration);
@@ -205,7 +205,7 @@ public class PremiumManager
premiumData.remove(accountName); premiumData.remove(accountName);
// UPDATE DATABASE // UPDATE DATABASE
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stmt = con.prepareStatement(DELETE_SQL)) PreparedStatement stmt = con.prepareStatement(DELETE_SQL))
{ {
stmt.setString(1, accountName); stmt.setString(1, accountName);

View File

@@ -56,7 +56,7 @@ public final class PunishmentManager
int expired = 0; int expired = 0;
// Load punishments. // Load punishments.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -57,7 +57,7 @@ public final class SiegeGuardManager
private void load() private void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
ResultSet rs = con.createStatement().executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1")) ResultSet rs = con.createStatement().executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1"))
{ {
while (rs.next()) while (rs.next())
@@ -158,7 +158,7 @@ public final class SiegeGuardManager
final SiegeGuardHolder holder = getSiegeGuardByItem(castle.getResidenceId(), itemId); final SiegeGuardHolder holder = getSiegeGuardByItem(castle.getResidenceId(), itemId);
if (holder != null) if (holder != null)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)")) PreparedStatement statement = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)"))
{ {
statement.setInt(1, castle.getResidenceId()); statement.setInt(1, castle.getResidenceId());
@@ -249,7 +249,7 @@ public final class SiegeGuardManager
*/ */
private void loadSiegeGuard(Castle castle) private void loadSiegeGuard(Castle castle)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, castle.getResidenceId()); ps.setInt(1, castle.getResidenceId());
@@ -283,7 +283,7 @@ public final class SiegeGuardManager
*/ */
public void removeSiegeGuard(int npcId, IPositionable pos) public void removeSiegeGuard(int npcId, IPositionable pos)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -304,7 +304,7 @@ public final class SiegeGuardManager
*/ */
public void removeSiegeGuards(Castle castle) public void removeSiegeGuards(Castle castle)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, castle.getResidenceId()); ps.setInt(1, castle.getResidenceId());

View File

@@ -88,7 +88,7 @@ public final class SiegeManager
} }
boolean register = false; boolean register = false;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?")) PreparedStatement statement = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?"))
{ {
statement.setInt(1, clan.getId()); statement.setInt(1, clan.getId());
@@ -275,7 +275,7 @@ public final class SiegeManager
private void loadTrapUpgrade(int castleId) private void loadTrapUpgrade(int castleId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -71,7 +71,7 @@ public class BlockList
private static List<Integer> loadList(int ObjId) private static List<Integer> loadList(int ObjId)
{ {
final List<Integer> list = new ArrayList<>(); final List<Integer> list = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1")) PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1"))
{ {
statement.setInt(1, ObjId); statement.setInt(1, ObjId);
@@ -98,7 +98,7 @@ public class BlockList
private void updateInDB(int targetId, boolean state) private void updateInDB(int targetId, boolean state)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
if (state) // add if (state) // add
{ {

View File

@@ -136,7 +136,7 @@ public class CursedWeapon implements INamable
// Remove from Db // Remove from Db
LOGGER.info(_name + " being removed offline."); LOGGER.info(_name + " being removed offline.");
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 reputation=?, pkkills=? WHERE charId=?")) PreparedStatement ps = con.prepareStatement("UPDATE characters SET reputation=?, pkkills=? WHERE charId=?"))
{ {
@@ -471,7 +471,7 @@ public class CursedWeapon implements INamable
public void saveData() public void saveData()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, playerReputation, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerReputation, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
{ {

View File

@@ -265,7 +265,7 @@ public class L2Clan implements IIdentifiable, INamable
} }
else else
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -305,7 +305,7 @@ public class L2Clan implements IIdentifiable, INamable
} }
else else
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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));
@@ -882,7 +882,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateBloodAllianceCountInDB() public void updateBloodAllianceCountInDB()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _bloodAllianceCount); ps.setInt(1, _bloodAllianceCount);
@@ -926,7 +926,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateBloodOathCountInDB() public void updateBloodOathCountInDB()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _bloodOathCount); ps.setInt(1, _bloodOathCount);
@@ -942,7 +942,7 @@ public class L2Clan implements IIdentifiable, INamable
public void updateInDB() public void updateInDB()
{ {
// Update reputation // Update reputation
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _reputationScore); ps.setInt(1, _reputationScore);
@@ -977,7 +977,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void updateClanInDB() public void updateClanInDB()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1015,7 +1015,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
public void store() public void store()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA)) PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
{ {
ps.setInt(1, _clanId); ps.setInt(1, _clanId);
@@ -1046,7 +1046,7 @@ public class L2Clan implements IIdentifiable, INamable
*/ */
private void removeMemberInDatabase(L2ClanMember member, long clanJoinExpiryTime, long clanCreateExpiryTime) private void removeMemberInDatabase(L2ClanMember member, long clanJoinExpiryTime, long clanCreateExpiryTime)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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=?"))
@@ -1071,7 +1071,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restore() private void restore()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA)) PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
{ {
ps.setInt(1, _clanId); ps.setInt(1, _clanId);
@@ -1146,7 +1146,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreNotice() private void restoreNotice()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _clanId); ps.setInt(1, _clanId);
@@ -1177,7 +1177,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _clanId); ps.setInt(1, _clanId);
@@ -1236,7 +1236,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreSkills() private void restoreSkills()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -1359,7 +1359,7 @@ public class L2Clan implements IIdentifiable, INamable
} }
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
if (oldSkill != null) if (oldSkill != null)
{ {
@@ -1769,7 +1769,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreSubPledges() private void restoreSubPledges()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -1869,7 +1869,7 @@ public class L2Clan implements IIdentifiable, INamable
return null; return null;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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, _clanId); ps.setInt(1, _clanId);
@@ -1952,7 +1952,7 @@ public class L2Clan implements IIdentifiable, INamable
public void updateSubPledgeInDB(int pledgeType) public void updateSubPledgeInDB(int pledgeType)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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());
@@ -1969,7 +1969,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreRankPrivs() private void restoreRankPrivs()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -2018,7 +2018,7 @@ public class L2Clan implements IIdentifiable, INamable
{ {
_privs.get(rank).setPrivs(privs); _privs.get(rank).setPrivs(privs);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -2054,7 +2054,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 = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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
@@ -2173,7 +2173,7 @@ public class L2Clan implements IIdentifiable, INamable
if (storeInDb) if (storeInDb)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -2716,7 +2716,7 @@ public class L2Clan implements IIdentifiable, INamable
public void changeLevel(int level) public void changeLevel(int level)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -2762,7 +2762,7 @@ public class L2Clan implements IIdentifiable, INamable
setCrestId(crestId); setCrestId(crestId);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -2799,7 +2799,7 @@ public class L2Clan implements IIdentifiable, INamable
allyId = _allyId; allyId = _allyId;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(sqlStatement)) PreparedStatement ps = con.prepareStatement(sqlStatement))
{ {
ps.setInt(1, crestId); ps.setInt(1, crestId);
@@ -2845,7 +2845,7 @@ public class L2Clan implements IIdentifiable, INamable
setCrestLargeId(crestId); setCrestLargeId(crestId);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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

@@ -244,7 +244,7 @@ public class L2ClanMember
*/ */
public void updatePledgeType() public void updatePledgeType()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -289,7 +289,7 @@ public class L2ClanMember
*/ */
public void updatePowerGrade() public void updatePowerGrade()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);
@@ -800,7 +800,7 @@ public class L2ClanMember
*/ */
public void saveApprenticeAndSponsor(int apprentice, int sponsor) public void saveApprenticeAndSponsor(int apprentice, int sponsor)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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);

View File

@@ -58,7 +58,7 @@ public class L2ContactList
{ {
_contacts.clear(); _contacts.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_LOAD)) PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
{ {
statement.setInt(1, activeChar.getObjectId()); statement.setInt(1, activeChar.getObjectId());
@@ -124,7 +124,7 @@ public class L2ContactList
} }
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_ADD)) PreparedStatement statement = con.prepareStatement(QUERY_ADD))
{ {
statement.setInt(1, activeChar.getObjectId()); statement.setInt(1, activeChar.getObjectId());
@@ -161,7 +161,7 @@ public class L2ContactList
_contacts.remove(name); _contacts.remove(name);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_REMOVE)) PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
{ {
statement.setInt(1, activeChar.getObjectId()); statement.setInt(1, activeChar.getObjectId());

View File

@@ -49,7 +49,7 @@ public class L2Mentee
final L2PcInstance player = getPlayerInstance(); final L2PcInstance player = getPlayerInstance();
if (player == null) // Only if player is offline if (player == null) // Only if player is offline
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?")) PreparedStatement statement = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
{ {
statement.setInt(1, _objectId); statement.setInt(1, _objectId);

View File

@@ -124,7 +124,7 @@ public class MacroList implements IRestorable
private void registerMacroInDb(Macro macro) private void registerMacroInDb(Macro macro)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());
@@ -160,7 +160,7 @@ public class MacroList implements IRestorable
private void deleteMacroFromDb(Macro macro) private void deleteMacroFromDb(Macro macro)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());
@@ -177,7 +177,7 @@ public class MacroList implements IRestorable
public boolean restoreMe() public boolean restoreMe()
{ {
_macroses.clear(); _macroses.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?")) PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
{ {
ps.setInt(1, _owner.getObjectId()); ps.setInt(1, _owner.getObjectId());

View File

@@ -85,7 +85,7 @@ public class ShortCuts implements IRestorable
deleteShortCutFromDb(oldShortCut); deleteShortCutFromDb(oldShortCut);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,sub_level,class_index) values(?,?,?,?,?,?,?,?)")) PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,sub_level,class_index) values(?,?,?,?,?,?,?,?)"))
{ {
statement.setInt(1, _owner.getObjectId()); statement.setInt(1, _owner.getObjectId());
@@ -154,7 +154,7 @@ public class ShortCuts implements IRestorable
*/ */
private void deleteShortCutFromDb(Shortcut shortcut) private void deleteShortCutFromDb(Shortcut shortcut)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
{ {
statement.setInt(1, _owner.getObjectId()); statement.setInt(1, _owner.getObjectId());
@@ -173,7 +173,7 @@ public class ShortCuts implements IRestorable
public boolean restoreMe() public boolean restoreMe()
{ {
_shortCuts.clear(); _shortCuts.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level, sub_level FROM character_shortcuts WHERE charId=? AND class_index=?")) PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level, sub_level FROM character_shortcuts WHERE charId=? AND class_index=?"))
{ {
statement.setInt(1, _owner.getObjectId()); statement.setInt(1, _owner.getObjectId());

View File

@@ -1343,7 +1343,7 @@ public final class L2PcInstance extends L2Playable
private void insertNewRecipeData(int recipeId, boolean isDwarf) private void insertNewRecipeData(int recipeId, boolean isDwarf)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)"))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -1360,7 +1360,7 @@ public final class L2PcInstance extends L2Playable
private void deleteRecipeData(int recipeId, boolean isDwarf) private void deleteRecipeData(int recipeId, boolean isDwarf)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?"))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -6334,7 +6334,7 @@ public final class L2PcInstance extends L2Playable
if (updateInDb) if (updateInDb)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER_ACCESS)) PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER_ACCESS))
{ {
ps.setInt(1, accessLevel.getLevel()); ps.setInt(1, accessLevel.getLevel());
@@ -6453,7 +6453,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public void updateOnlineStatus() public void updateOnlineStatus()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?")) PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?"))
{ {
statement.setInt(1, isOnlineInt()); statement.setInt(1, isOnlineInt());
@@ -6473,7 +6473,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private boolean createDb() private boolean createDb()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_CHARACTER)) PreparedStatement statement = con.prepareStatement(INSERT_CHARACTER))
{ {
statement.setString(1, _accountName); statement.setString(1, _accountName);
@@ -6537,7 +6537,7 @@ public final class L2PcInstance extends L2Playable
double currentCp = 0; double currentCp = 0;
double currentHp = 0; double currentHp = 0;
double currentMp = 0; double currentMp = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER)) PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER))
{ {
// Retrieve the L2PcInstance from the characters table of the database // Retrieve the L2PcInstance from the characters table of the database
@@ -6898,7 +6898,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private static boolean restoreSubClassData(L2PcInstance player) private static boolean restoreSubClassData(L2PcInstance player)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_SUBCLASSES)) PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
{ {
statement.setInt(1, player.getObjectId()); statement.setInt(1, player.getObjectId());
@@ -6989,7 +6989,7 @@ public final class L2PcInstance extends L2Playable
private void restoreRecipeBook(boolean loadCommon) private void restoreRecipeBook(boolean loadCommon)
{ {
final String sql = loadCommon ? "SELECT id, type, classIndex FROM character_recipebook WHERE charId=?" : "SELECT id FROM character_recipebook WHERE charId=? AND classIndex=? AND type = 1"; final String sql = loadCommon ? "SELECT id, type, classIndex FROM character_recipebook WHERE charId=?" : "SELECT id FROM character_recipebook WHERE charId=? AND classIndex=? AND type = 1";
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(sql)) PreparedStatement statement = con.prepareStatement(sql))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -7042,7 +7042,7 @@ public final class L2PcInstance extends L2Playable
private void loadPremiumItemList() private void loadPremiumItemList()
{ {
final String sql = "SELECT itemNum, itemId, itemCount, itemSender FROM character_premium_items WHERE charId=?"; final String sql = "SELECT itemNum, itemId, itemCount, itemSender FROM character_premium_items WHERE charId=?";
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(sql)) PreparedStatement statement = con.prepareStatement(sql))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -7066,7 +7066,7 @@ public final class L2PcInstance extends L2Playable
public void updatePremiumItem(int itemNum, long newcount) public void updatePremiumItem(int itemNum, long newcount)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? ")) PreparedStatement statement = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? "))
{ {
statement.setLong(1, newcount); statement.setLong(1, newcount);
@@ -7082,7 +7082,7 @@ public final class L2PcInstance extends L2Playable
public void deletePremiumItem(int itemNum) public void deletePremiumItem(int itemNum)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? ")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? "))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -7135,7 +7135,7 @@ public final class L2PcInstance extends L2Playable
final long exp = getStat().getBaseExp(); final long exp = getStat().getBaseExp();
final int level = getStat().getBaseLevel(); final int level = getStat().getBaseLevel();
final long sp = getStat().getBaseSp(); final long sp = getStat().getBaseSp();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER)) PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER))
{ {
statement.setInt(1, level); statement.setInt(1, level);
@@ -7220,7 +7220,7 @@ public final class L2PcInstance extends L2Playable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CHAR_SUBCLASS)) PreparedStatement statement = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
{ {
for (SubClass subClass : getSubClasses().values()) for (SubClass subClass : getSubClasses().values())
@@ -7251,7 +7251,7 @@ public final class L2PcInstance extends L2Playable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE); PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE);
PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE)) PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE))
{ {
@@ -7371,7 +7371,7 @@ public final class L2PcInstance extends L2Playable
private void storeItemReuseDelay() private void storeItemReuseDelay()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE); PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE)) PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE))
{ {
@@ -7488,7 +7488,7 @@ public final class L2PcInstance extends L2Playable
final Skill oldSkill = super.removeSkill(skill, true); final Skill oldSkill = super.removeSkill(skill, true);
if (oldSkill != null) if (oldSkill != null)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR)) PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
{ {
// Remove or update a L2PcInstance skill from the character_skills table of the database // Remove or update a L2PcInstance skill from the character_skills table of the database
@@ -7531,7 +7531,7 @@ public final class L2PcInstance extends L2Playable
private void storeSkill(Skill newSkill, Skill oldSkill, int newClassIndex) private void storeSkill(Skill newSkill, Skill oldSkill, int newClassIndex)
{ {
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex; final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
if ((oldSkill != null) && (newSkill != null)) if ((oldSkill != null) && (newSkill != null))
{ {
@@ -7581,7 +7581,7 @@ public final class L2PcInstance extends L2Playable
} }
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex; final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS)) PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS))
{ {
con.setAutoCommit(false); con.setAutoCommit(false);
@@ -7608,7 +7608,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void restoreSkills() private void restoreSkills()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR)) PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
{ {
// Retrieve all skills of this L2PcInstance from the database // Retrieve all skills of this L2PcInstance from the database
@@ -7660,7 +7660,7 @@ public final class L2PcInstance extends L2Playable
@Override @Override
public void restoreEffects() public void restoreEffects()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE)) PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -7717,7 +7717,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void restoreItemReuse() private void restoreItemReuse()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE); PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE)) PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE))
{ {
@@ -7788,7 +7788,7 @@ public final class L2PcInstance extends L2Playable
_henna[i - 1] = null; _henna[i - 1] = null;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS)) PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -7896,7 +7896,7 @@ public final class L2PcInstance extends L2Playable
_henna[slot - 1] = null; _henna[slot - 1] = null;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA)) PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -7994,7 +7994,7 @@ public final class L2PcInstance extends L2Playable
// Calculate Henna modifiers of this L2PcInstance // Calculate Henna modifiers of this L2PcInstance
recalcHennaStats(); recalcHennaStats();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA)) PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -9631,7 +9631,7 @@ public final class L2PcInstance extends L2Playable
newClass.setLevel(Config.BASE_DUALCLASS_LEVEL); newClass.setLevel(Config.BASE_DUALCLASS_LEVEL);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS)) PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS))
{ {
// Store the basic info about this new sub-class. // Store the basic info about this new sub-class.
@@ -9731,7 +9731,7 @@ public final class L2PcInstance extends L2Playable
// Remove after stats are recalculated. // Remove after stats are recalculated.
getSubClasses().remove(classIndex); getSubClasses().remove(classIndex);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS); PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS);
PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS); PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE); PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE);
@@ -11968,7 +11968,7 @@ public final class L2PcInstance extends L2Playable
{ {
String req; String req;
req = "UPDATE pets SET fed=? WHERE item_obj_id = ?"; req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(req)) PreparedStatement statement = con.prepareStatement(req))
{ {
statement.setInt(1, _curFeed); statement.setInt(1, _curFeed);
@@ -12095,7 +12095,7 @@ public final class L2PcInstance extends L2Playable
bookmark.setTag(tag); bookmark.setTag(tag);
bookmark.setName(name); bookmark.setName(name);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK)) PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK))
{ {
statement.setInt(1, icon); statement.setInt(1, icon);
@@ -12118,7 +12118,7 @@ public final class L2PcInstance extends L2Playable
{ {
if (_tpbookmarks.remove(id) != null) if (_tpbookmarks.remove(id) != null)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK)) PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -12261,7 +12261,7 @@ public final class L2PcInstance extends L2Playable
sm.addItemName(20033); sm.addItemName(20033);
sendPacket(sm); sendPacket(sm);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK)) PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -12283,7 +12283,7 @@ public final class L2PcInstance extends L2Playable
public void restoreTeleportBookmark() public void restoreTeleportBookmark()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK)) PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -12495,7 +12495,7 @@ public final class L2PcInstance extends L2Playable
_friendList.clear(); _friendList.clear();
final String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0"; final String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0";
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(sqlQuery)) PreparedStatement statement = con.prepareStatement(sqlQuery))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -12585,7 +12585,7 @@ public final class L2PcInstance extends L2Playable
{ {
if (hasManufactureShop()) if (hasManufactureShop())
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP)) try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
{ {
@@ -12623,7 +12623,7 @@ public final class L2PcInstance extends L2Playable
_manufactureItems.clear(); _manufactureItems.clear();
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP)) PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -13041,7 +13041,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void restorePetInventoryItems() private void restorePetInventoryItems()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;")) PreparedStatement statement = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -13081,7 +13081,7 @@ public final class L2PcInstance extends L2Playable
*/ */
private void loadRecommendations() private void loadRecommendations()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT rec_have, rec_left FROM character_reco_bonus WHERE charId = ?")) PreparedStatement statement = con.prepareStatement("SELECT rec_have, rec_left FROM character_reco_bonus WHERE charId = ?"))
{ {
statement.setInt(1, getObjectId()); statement.setInt(1, getObjectId());
@@ -13105,7 +13105,7 @@ public final class L2PcInstance extends L2Playable
*/ */
public void storeRecommendations() public void storeRecommendations()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?)"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());

View File

@@ -788,7 +788,7 @@ public class L2PetInstance extends L2Summon
} }
// pet control item no longer exists, delete the pet from the db // pet control item no longer exists, delete the pet from the db
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?")) PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
{ {
statement.setInt(1, _controlObjectId); statement.setInt(1, _controlObjectId);
@@ -846,7 +846,7 @@ public class L2PetInstance extends L2Summon
private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner) private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?")) PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
{ {
L2PetInstance pet; L2PetInstance pet;
@@ -942,7 +942,7 @@ public class L2PetInstance extends L2Summon
req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? WHERE item_obj_id = ?"; req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? WHERE item_obj_id = ?";
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(req)) PreparedStatement statement = con.prepareStatement(req))
{ {
statement.setString(1, getName()); statement.setString(1, getName());
@@ -992,7 +992,7 @@ public class L2PetInstance extends L2Summon
// Clear list for overwrite // Clear list for overwrite
SummonEffectsTable.getInstance().getPetEffects().getOrDefault(getControlObjectId(), Collections.emptyList()).clear(); SummonEffectsTable.getInstance().getPetEffects().getOrDefault(getControlObjectId(), Collections.emptyList()).clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE); PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE)) PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
{ {
@@ -1067,7 +1067,7 @@ public class L2PetInstance extends L2Summon
@Override @Override
public void restoreEffects() public void restoreEffects()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE); PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE)) PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
{ {

View File

@@ -288,7 +288,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).getOrDefault(getReferenceSkill(), Collections.emptyList()).clear(); SummonEffectsTable.getInstance().getServitorEffects(getOwner()).getOrDefault(getReferenceSkill(), Collections.emptyList()).clear();
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE)) PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
{ {
// Delete all current stored effects for summon to avoid dupe // Delete all current stored effects for summon to avoid dupe
@@ -389,7 +389,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()) || !SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()) || !SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill())) if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()) || !SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()) || !SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
{ {

View File

@@ -108,7 +108,7 @@ public class Announcement implements IAnnouncement
@Override @Override
public boolean storeMe() public boolean storeMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS)) PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{ {
ps.setInt(1, _type.ordinal()); ps.setInt(1, _type.ordinal());
@@ -134,7 +134,7 @@ public class Announcement implements IAnnouncement
@Override @Override
public boolean updateMe() public boolean updateMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY)) PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{ {
ps.setInt(1, _type.ordinal()); ps.setInt(1, _type.ordinal());
@@ -154,7 +154,7 @@ public class Announcement implements IAnnouncement
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_QUERY)) PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
{ {
ps.setInt(1, _id); ps.setInt(1, _id);

View File

@@ -94,7 +94,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override @Override
public boolean storeMe() public boolean storeMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS)) PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{ {
st.setInt(1, getType().ordinal()); st.setInt(1, getType().ordinal());
@@ -123,7 +123,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override @Override
public boolean updateMe() public boolean updateMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(UPDATE_QUERY)) PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
{ {
st.setInt(1, getType().ordinal()); st.setInt(1, getType().ordinal());

View File

@@ -157,7 +157,7 @@ public final class Product
private void save() private void save()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?")) PreparedStatement statement = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?"))
{ {
statement.setInt(1, _buyListId); statement.setInt(1, _buyListId);

View File

@@ -58,7 +58,7 @@ public class ClanHallAuction
private final void loadBidder() private final void loadBidder()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(LOAD_CLANHALL_BIDDERS)) PreparedStatement ps = con.prepareStatement(LOAD_CLANHALL_BIDDERS))
{ {
ps.setInt(1, _clanHallId); ps.setInt(1, _clanHallId);
@@ -102,7 +102,7 @@ public class ClanHallAuction
} }
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CLANHALL_BIDDER)) PreparedStatement ps = con.prepareStatement(INSERT_CLANHALL_BIDDER))
{ {
ps.setInt(1, _clanHallId); ps.setInt(1, _clanHallId);
@@ -121,7 +121,7 @@ public class ClanHallAuction
public void removeBid(L2Clan clan) public void removeBid(L2Clan clan)
{ {
getBids().remove(clan.getId()); getBids().remove(clan.getId());
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_CLANHALL_BIDDER)) PreparedStatement ps = con.prepareStatement(DELETE_CLANHALL_BIDDER))
{ {
ps.setInt(1, clan.getId()); ps.setInt(1, clan.getId());
@@ -170,7 +170,7 @@ public class ClanHallAuction
clanHall.setOwner(highestBidder.getClan()); clanHall.setOwner(highestBidder.getClan());
getBids().clear(); getBids().clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_CLANHALL_BIDDERS)) PreparedStatement ps = con.prepareStatement(DELETE_CLANHALL_BIDDERS))
{ {
ps.setInt(1, _clanHallId); ps.setInt(1, _clanHallId);

View File

@@ -218,7 +218,7 @@ public final class Castle extends AbstractResidence
public void dbSave() public void dbSave()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -360,7 +360,7 @@ public final class Castle extends AbstractResidence
_treasury += amount; _treasury += amount;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
{ {
ps.setLong(1, _treasury); ps.setLong(1, _treasury);
@@ -643,7 +643,7 @@ public final class Castle extends AbstractResidence
@Override @Override
protected void load() protected void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?"); PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?")) PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
{ {
@@ -689,7 +689,7 @@ public final class Castle extends AbstractResidence
/** Load All Functions */ /** Load All Functions */
private void loadFunctions() private void loadFunctions()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -714,7 +714,7 @@ public final class Castle extends AbstractResidence
public void removeFunction(int functionType) public void removeFunction(int functionType)
{ {
_function.remove(functionType); _function.remove(functionType);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -786,7 +786,7 @@ public final class Castle extends AbstractResidence
// This method loads castle door upgrade data from database // This method loads castle door upgrade data from database
private void loadDoorUpgrade() private void loadDoorUpgrade()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -812,7 +812,7 @@ public final class Castle extends AbstractResidence
door.setCurrentHp(door.getCurrentHp()); door.setCurrentHp(door.getCurrentHp());
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -837,7 +837,7 @@ public final class Castle extends AbstractResidence
if (save) if (save)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)"))
{ {
ps.setInt(1, doorId); ps.setInt(1, doorId);
@@ -864,7 +864,7 @@ public final class Castle extends AbstractResidence
CastleManorManager.getInstance().resetManorData(getResidenceId()); CastleManorManager.getInstance().resetManorData(getResidenceId());
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Need to remove has castle flag from clan_data, should be checked from castle table. // Need to remove has castle flag from clan_data, should be checked from castle table.
try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?")) try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?"))
@@ -1032,7 +1032,7 @@ public final class Castle extends AbstractResidence
public void updateShowNpcCrest() public void updateShowNpcCrest()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
{ {
ps.setString(1, String.valueOf(_showNpcCrest)); ps.setString(1, String.valueOf(_showNpcCrest));
@@ -1076,7 +1076,7 @@ public final class Castle extends AbstractResidence
{ {
_ticketBuyCount = count; _ticketBuyCount = count;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
{ {
ps.setInt(1, _ticketBuyCount); ps.setInt(1, _ticketBuyCount);
@@ -1099,7 +1099,7 @@ public final class Castle extends AbstractResidence
{ {
if (save) if (save)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -1126,7 +1126,7 @@ public final class Castle extends AbstractResidence
ts.setUpgradeLevel(0); ts.setUpgradeLevel(0);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -1209,7 +1209,7 @@ public final class Castle extends AbstractResidence
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
{ {
ps.setString(1, side.toString()); ps.setString(1, side.toString());

View File

@@ -100,7 +100,7 @@ public final class ClanHall extends AbstractResidence
@Override @Override
protected void load() protected void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement loadStatement = con.prepareStatement(LOAD_CLANHALL); PreparedStatement loadStatement = con.prepareStatement(LOAD_CLANHALL);
PreparedStatement insertStatement = con.prepareStatement(INSERT_CLANHALL)) PreparedStatement insertStatement = con.prepareStatement(INSERT_CLANHALL))
{ {
@@ -133,7 +133,7 @@ public final class ClanHall extends AbstractResidence
public void updateDB() public void updateDB()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CLANHALL)) PreparedStatement statement = con.prepareStatement(UPDATE_CLANHALL))
{ {
statement.setInt(1, getOwnerId()); statement.setInt(1, getOwnerId());

View File

@@ -45,7 +45,7 @@ public class Couple
{ {
_Id = coupleId; _Id = coupleId;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
{ {
ps.setInt(1, _Id); ps.setInt(1, _Id);
@@ -85,7 +85,7 @@ public class Couple
_weddingDate = Calendar.getInstance(); _weddingDate = Calendar.getInstance();
_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis()); _weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
{ {
_Id = IdFactory.getInstance().getNextId(); _Id = IdFactory.getInstance().getNextId();
@@ -105,7 +105,7 @@ public class Couple
public void marry() public void marry()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?"))
{ {
ps.setBoolean(1, true); ps.setBoolean(1, true);
@@ -123,7 +123,7 @@ public class Couple
public void divorce() public void divorce()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?"))
{ {
ps.setInt(1, _Id); ps.setInt(1, _Id);

View File

@@ -214,7 +214,7 @@ public final class Fort extends AbstractResidence
public void dbSave() public void dbSave()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -487,7 +487,7 @@ public final class Fort extends AbstractResidence
public void saveFortVariables() public void saveFortVariables()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
{ {
ps.setInt(1, _supplyLvL); ps.setInt(1, _supplyLvL);
@@ -552,7 +552,7 @@ public final class Fort extends AbstractResidence
@Override @Override
protected void load() protected void load()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -613,7 +613,7 @@ public final class Fort extends AbstractResidence
/** Load All Functions */ /** Load All Functions */
private void loadFunctions() private void loadFunctions()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -638,7 +638,7 @@ public final class Fort extends AbstractResidence
public void removeFunction(int functionType) public void removeFunction(int functionType)
{ {
_function.remove(functionType); _function.remove(functionType);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -730,7 +730,7 @@ public final class Fort extends AbstractResidence
// This method loads fort door upgrade data from database // This method loads fort door upgrade data from database
private void loadDoorUpgrade() private void loadDoorUpgrade()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -750,7 +750,7 @@ public final class Fort extends AbstractResidence
private void removeDoorUpgrade() private void removeDoorUpgrade()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -764,7 +764,7 @@ public final class Fort extends AbstractResidence
private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef) private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
{ {
ps.setInt(1, doorId); ps.setInt(1, doorId);
@@ -793,7 +793,7 @@ public final class Fort extends AbstractResidence
_lastOwnedTime.setTimeInMillis(0); _lastOwnedTime.setTimeInMillis(0);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?"))
{ {
ps.setInt(1, clanId); ps.setInt(1, clanId);
@@ -998,7 +998,7 @@ public final class Fort extends AbstractResidence
{ {
_state = state; _state = state;
_castleId = castleId; _castleId = castleId;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
{ {
ps.setInt(1, _state); ps.setInt(1, _state);
@@ -1130,7 +1130,7 @@ public final class Fort extends AbstractResidence
private void initNpcs() private void initNpcs()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -1159,7 +1159,7 @@ public final class Fort extends AbstractResidence
private void initSiegeNpcs() private void initSiegeNpcs()
{ {
_siegeNpcs.clear(); _siegeNpcs.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id")) PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -1186,7 +1186,7 @@ public final class Fort extends AbstractResidence
private void initNpcCommanders() private void initNpcCommanders()
{ {
_npcCommanders.clear(); _npcCommanders.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id")) PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());
@@ -1216,7 +1216,7 @@ public final class Fort extends AbstractResidence
_specialEnvoys.clear(); _specialEnvoys.clear();
_envoyCastles.clear(); _envoyCastles.clear();
_availableCastles.clear(); _availableCastles.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading, castleId FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id")) PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading, castleId FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
{ {
ps.setInt(1, getResidenceId()); ps.setInt(1, getResidenceId());

View File

@@ -501,7 +501,7 @@ public class FortSiege implements Siegable
/** Clear all registered siege clans from database for fort */ /** Clear all registered siege clans from database for fort */
public void clearSiegeClan() public void clearSiegeClan()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?")) PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?"))
{ {
ps.setInt(1, _fort.getResidenceId()); ps.setInt(1, _fort.getResidenceId());
@@ -785,7 +785,7 @@ public class FortSiege implements Siegable
private void removeSiegeClan(int clanId) private void removeSiegeClan(int clanId)
{ {
final String query = (clanId != 0) ? DELETE_FORT_SIEGECLANS_BY_CLAN_ID : DELETE_FORT_SIEGECLANS; final String query = (clanId != 0) ? DELETE_FORT_SIEGECLANS_BY_CLAN_ID : DELETE_FORT_SIEGECLANS;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(query)) PreparedStatement statement = con.prepareStatement(query))
{ {
statement.setInt(1, _fort.getResidenceId()); statement.setInt(1, _fort.getResidenceId());
@@ -999,7 +999,7 @@ public class FortSiege implements Siegable
private void loadSiegeClan() private void loadSiegeClan()
{ {
_attackerClans.clear(); _attackerClans.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?")) PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?"))
{ {
ps.setInt(1, _fort.getResidenceId()); ps.setInt(1, _fort.getResidenceId());
@@ -1057,7 +1057,7 @@ public class FortSiege implements Siegable
/** Save siege date to database. */ /** Save siege date to database. */
private void saveSiegeDate() private void saveSiegeDate()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?"))
{ {
ps.setLong(1, _fort.getSiegeDate().getTimeInMillis()); ps.setLong(1, _fort.getSiegeDate().getTimeInMillis());
@@ -1081,7 +1081,7 @@ public class FortSiege implements Siegable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
{ {
statement.setInt(1, clan.getId()); statement.setInt(1, clan.getId());
@@ -1146,7 +1146,7 @@ public class FortSiege implements Siegable
public void loadSiegeGuard() public void loadSiegeGuard()
{ {
_siegeGuards.clear(); _siegeGuards.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.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 = _fort.getResidenceId(); final int fortId = _fort.getResidenceId();

View File

@@ -114,7 +114,7 @@ public class Hero
_herodiary.clear(); _herodiary.clear();
_heroMessage.clear(); _heroMessage.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
Statement s1 = con.createStatement(); Statement s1 = con.createStatement();
ResultSet rset = s1.executeQuery(GET_HEROES); ResultSet rset = s1.executeQuery(GET_HEROES);
PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY); PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
@@ -211,7 +211,7 @@ public class Hero
*/ */
public void loadMessage(int charId) public void loadMessage(int charId)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT message FROM heroes WHERE charId=?")) PreparedStatement statement = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
{ {
statement.setInt(1, charId); statement.setInt(1, charId);
@@ -233,7 +233,7 @@ public class Hero
{ {
final List<StatsSet> _diary = new CopyOnWriteArrayList<>(); final List<StatsSet> _diary = new CopyOnWriteArrayList<>();
int diaryentries = 0; int diaryentries = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC")) PreparedStatement statement = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
{ {
statement.setInt(1, charId); statement.setInt(1, charId);
@@ -300,7 +300,7 @@ public class Hero
int _losses = 0; int _losses = 0;
int _draws = 0; int _draws = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC")) PreparedStatement statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
{ {
statement.setInt(1, charId); statement.setInt(1, charId);
@@ -699,7 +699,7 @@ public class Hero
public void updateHeroes(boolean setDefault) public void updateHeroes(boolean setDefault)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
if (setDefault) if (setDefault)
{ {
@@ -841,7 +841,7 @@ public class Hero
public void setDiaryData(int charId, int action, int param) public void setDiaryData(int charId, int action, int param)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
{ {
statement.setInt(1, charId); statement.setInt(1, charId);
@@ -877,7 +877,7 @@ public class Hero
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;")) PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{ {
statement.setString(1, _heroMessage.get(charId)); statement.setString(1, _heroMessage.get(charId));
@@ -892,7 +892,7 @@ public class Hero
private void deleteItemsInDb() private void deleteItemsInDb()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_ITEMS)) PreparedStatement statement = con.prepareStatement(DELETE_ITEMS))
{ {
statement.execute(); statement.execute();

View File

@@ -760,7 +760,7 @@ public class Siege implements Siegable
/** Clear all registered siege clans from database for castle */ /** Clear all registered siege clans from database for castle */
public void clearSiegeClan() public void clearSiegeClan()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?")) PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
{ {
statement.setInt(1, _castle.getResidenceId()); statement.setInt(1, _castle.getResidenceId());
@@ -788,7 +788,7 @@ public class Siege implements Siegable
/** Clear all siege clans waiting for approval from database for castle */ /** Clear all siege clans waiting for approval from database for castle */
public void clearSiegeWaitingClan() public void clearSiegeWaitingClan()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2")) PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
{ {
statement.setInt(1, _castle.getResidenceId()); statement.setInt(1, _castle.getResidenceId());
@@ -972,7 +972,7 @@ public class Siege implements Siegable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?")) PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
{ {
statement.setInt(1, _castle.getResidenceId()); statement.setInt(1, _castle.getResidenceId());
@@ -1238,7 +1238,7 @@ public class Siege implements Siegable
private void loadSiegeClan() private void loadSiegeClan()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?")) PreparedStatement statement = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
{ {
getAttackerClans().clear(); getAttackerClans().clear();
@@ -1349,7 +1349,7 @@ public class Siege implements Siegable
_scheduledStartSiegeTask = ThreadPool.schedule(new ScheduleStartSiegeTask(_castle), 1000); _scheduledStartSiegeTask = ThreadPool.schedule(new ScheduleStartSiegeTask(_castle), 1000);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?")) PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
{ {
statement.setLong(1, _castle.getSiegeDate().getTimeInMillis()); statement.setLong(1, _castle.getSiegeDate().getTimeInMillis());
@@ -1378,7 +1378,7 @@ public class Siege implements Siegable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER)) if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
{ {

View File

@@ -138,7 +138,7 @@ public class EventScheduler
public boolean updateLastRun() public boolean updateLastRun()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO event_schedulers (eventName, schedulerName, lastRun) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE eventName = ?, schedulerName = ?, lastRun = ?")) PreparedStatement ps = con.prepareStatement("INSERT INTO event_schedulers (eventName, schedulerName, lastRun) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE eventName = ?, schedulerName = ?, lastRun = ?"))
{ {
ps.setString(1, _eventManager.getName()); ps.setString(1, _eventManager.getName());

View File

@@ -52,7 +52,7 @@ public class HaventRunConditionalScheduler implements IConditionalEventScheduler
throw new NullPointerException("Scheduler not found: " + _name); throw new NullPointerException("Scheduler not found: " + _name);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT lastRun FROM event_schedulers WHERE eventName = ? AND schedulerName = ?")) PreparedStatement ps = con.prepareStatement("SELECT lastRun FROM event_schedulers WHERE eventName = ? AND schedulerName = ?"))
{ {
ps.setString(1, _eventManager.getName()); ps.setString(1, _eventManager.getName());

View File

@@ -815,7 +815,7 @@ public final class Instance implements IIdentifiable, INamable
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
{ {
// Save to database // Save to database

View File

@@ -191,7 +191,7 @@ public final class ItemAuction
public final void storeMe() public final void storeMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?")) PreparedStatement statement = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
{ {
statement.setInt(1, _auctionId); statement.setInt(1, _auctionId);
@@ -225,7 +225,7 @@ public final class ItemAuction
final void updatePlayerBidInternal(ItemAuctionBid bid, boolean delete) final void updatePlayerBidInternal(ItemAuctionBid bid, boolean delete)
{ {
final String query = delete ? DELETE_ITEM_AUCTION_BID : INSERT_ITEM_AUCTION_BID; final String query = delete ? DELETE_ITEM_AUCTION_BID : INSERT_ITEM_AUCTION_BID;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(query)) PreparedStatement ps = con.prepareStatement(query))
{ {
ps.setInt(1, _auctionId); ps.setInt(1, _auctionId);

View File

@@ -161,7 +161,7 @@ public final class ItemAuctionInstance
throw new IllegalArgumentException("No items defined"); throw new IllegalArgumentException("No items defined");
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_AUCTION_ID_BY_INSTANCE_ID)) PreparedStatement ps = con.prepareStatement(SELECT_AUCTION_ID_BY_INSTANCE_ID))
{ {
ps.setInt(1, _instanceId); ps.setInt(1, _instanceId);
@@ -533,7 +533,7 @@ public final class ItemAuctionInstance
private ItemAuction loadAuction(int auctionId) throws SQLException private ItemAuction loadAuction(int auctionId) throws SQLException
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
int auctionItemId = 0; int auctionItemId = 0;
long startingTime = 0; long startingTime = 0;

View File

@@ -1783,7 +1783,7 @@ public abstract class Inventory extends ItemContainer
@Override @Override
public void restore() public void restore()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data")) PreparedStatement ps = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
{ {
ps.setInt(1, getOwnerId()); ps.setInt(1, getOwnerId());

View File

@@ -673,7 +673,7 @@ public abstract class ItemContainer
*/ */
public void restore() public void restore()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=?)")) PreparedStatement ps = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=?)"))
{ {
ps.setInt(1, getOwnerId()); ps.setInt(1, getOwnerId());

View File

@@ -112,7 +112,7 @@ public class Mail extends ItemContainer
@Override @Override
public void restore() public void restore()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND loc=? AND loc_data=?")) PreparedStatement statement = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
{ {
statement.setInt(1, _ownerId); statement.setInt(1, _ownerId);

View File

@@ -738,7 +738,7 @@ public class PcInventory extends Inventory
public static int[][] restoreVisibleInventory(int objectId) public static int[][] restoreVisibleInventory(int objectId)
{ {
final int[][] paperdoll = new int[33][4]; final int[][] paperdoll = new int[33][4];
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement2 = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'")) PreparedStatement statement2 = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
{ {
statement2.setInt(1, objectId); statement2.setInt(1, objectId);

View File

@@ -976,7 +976,7 @@ public final class L2ItemInstance extends L2Object
final VariationInstance augment = _augmentation; final VariationInstance augment = _augmentation;
_augmentation = null; _augmentation = null;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId = ?"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -993,7 +993,7 @@ public final class L2ItemInstance extends L2Object
public void restoreAttributes() public void restoreAttributes()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT mineralId,option1,option2 FROM item_variations WHERE itemId=?"); PreparedStatement ps1 = con.prepareStatement("SELECT mineralId,option1,option2 FROM item_variations WHERE itemId=?");
PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?")) PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
{ {
@@ -1034,7 +1034,7 @@ public final class L2ItemInstance extends L2Object
public void updateItemOptions() public void updateItemOptions()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
updateItemOptions(con); updateItemOptions(con);
} }
@@ -1062,7 +1062,7 @@ public final class L2ItemInstance extends L2Object
public void updateItemElementals() public void updateItemElementals()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
updateItemElements(con); updateItemElements(con);
} }
@@ -1224,7 +1224,7 @@ public final class L2ItemInstance extends L2Object
_elementals.remove(type); _elementals.remove(type);
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -1249,7 +1249,7 @@ public final class L2ItemInstance extends L2Object
_elementals.clear(); _elementals.clear();
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ?"))
{ {
ps.setInt(1, getObjectId()); ps.setInt(1, getObjectId());
@@ -1581,7 +1581,7 @@ public final class L2ItemInstance extends L2Object
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? WHERE object_id = ?")) PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? WHERE object_id = ?"))
{ {
ps.setInt(1, _ownerId); ps.setInt(1, _ownerId);
@@ -1614,7 +1614,7 @@ public final class L2ItemInstance extends L2Object
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) VALUES (?,?,?,?,?,?,?,?,?,?,?)")) PreparedStatement ps = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) VALUES (?,?,?,?,?,?,?,?,?,?,?)"))
{ {
ps.setInt(1, _ownerId); ps.setInt(1, _ownerId);
@@ -1658,7 +1658,7 @@ public final class L2ItemInstance extends L2Object
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?")) try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?"))
{ {

View File

@@ -142,7 +142,7 @@ public class Olympiad extends ListenersContainer
{ {
_nobles.clear(); _nobles.clear();
boolean loaded = false; boolean loaded = false;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA); PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA);
ResultSet rset = statement.executeQuery()) ResultSet rset = statement.executeQuery())
{ {
@@ -221,7 +221,7 @@ public class Olympiad extends ListenersContainer
} }
} }
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES); PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);
ResultSet rset = statement.executeQuery()) ResultSet rset = statement.executeQuery())
{ {
@@ -295,7 +295,7 @@ public class Olympiad extends ListenersContainer
{ {
_noblesRank.clear(); _noblesRank.clear();
final Map<Integer, Integer> tmpPlace = new HashMap<>(); final Map<Integer, Integer> tmpPlace = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS); PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS);
ResultSet rset = statement.executeQuery()) ResultSet rset = statement.executeQuery())
{ {
@@ -806,7 +806,7 @@ public class Olympiad extends ListenersContainer
return; return;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
for (Entry<Integer, StatsSet> entry : _nobles.entrySet()) for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
{ {
@@ -878,7 +878,7 @@ public class Olympiad extends ListenersContainer
{ {
saveNobleData(); saveNobleData();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA)) PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA))
{ {
statement.setInt(1, _currentCycle); statement.setInt(1, _currentCycle);
@@ -919,7 +919,7 @@ public class Olympiad extends ListenersContainer
protected void updateMonthlyData() protected void updateMonthlyData()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(OLYMPIAD_MONTH_CLEAR); PreparedStatement ps1 = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
PreparedStatement ps2 = con.prepareStatement(OLYMPIAD_MONTH_CREATE)) PreparedStatement ps2 = con.prepareStatement(OLYMPIAD_MONTH_CREATE))
{ {
@@ -963,7 +963,7 @@ public class Olympiad extends ListenersContainer
final List<StatsSet> heroesToBe = new LinkedList<>(); final List<StatsSet> heroesToBe = new LinkedList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS)) PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
{ {
StatsSet hero; StatsSet hero;
@@ -998,7 +998,7 @@ public class Olympiad extends ListenersContainer
{ {
final List<String> names = new ArrayList<>(); final List<String> names = new ArrayList<>();
final String query = Config.ALT_OLY_SHOW_MONTHLY_WINNERS ? ((classId == 132) ? GET_EACH_CLASS_LEADER_SOULHOUND : GET_EACH_CLASS_LEADER) : ((classId == 132) ? GET_EACH_CLASS_LEADER_CURRENT_SOULHOUND : GET_EACH_CLASS_LEADER_CURRENT); final String query = Config.ALT_OLY_SHOW_MONTHLY_WINNERS ? ((classId == 132) ? GET_EACH_CLASS_LEADER_SOULHOUND : GET_EACH_CLASS_LEADER) : ((classId == 132) ? GET_EACH_CLASS_LEADER_CURRENT_SOULHOUND : GET_EACH_CLASS_LEADER_CURRENT);
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(query)) PreparedStatement ps = con.prepareStatement(query))
{ {
ps.setInt(1, classId); ps.setInt(1, classId);
@@ -1108,7 +1108,7 @@ public class Olympiad extends ListenersContainer
public int getLastNobleOlympiadPoints(int objId) public int getLastNobleOlympiadPoints(int objId)
{ {
int result = 0; int result = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?")) PreparedStatement ps = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?"))
{ {
ps.setInt(1, objId); ps.setInt(1, objId);
@@ -1252,7 +1252,7 @@ public class Olympiad extends ListenersContainer
protected void deleteNobles() protected void deleteNobles()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL)) PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL))
{ {
statement.execute(); statement.execute();

View File

@@ -743,7 +743,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type) protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)")) PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{ {
statement.setInt(1, one.getObjectId()); statement.setInt(1, one.getObjectId());

View File

@@ -185,7 +185,7 @@ public class PunishmentTask implements Runnable
{ {
if (!_isStored) if (!_isStored)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS)) PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{ {
st.setString(1, _key); st.setString(1, _key);
@@ -224,7 +224,7 @@ public class PunishmentTask implements Runnable
{ {
if (_isStored) if (_isStored)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(UPDATE_QUERY)) PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
{ {
st.setLong(1, System.currentTimeMillis()); st.setLong(1, System.currentTimeMillis());

View File

@@ -409,7 +409,7 @@ public class LongTimeEvent extends Quest
} }
} }
// Update database // Update database
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?")) PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
{ {
statement.setInt(1, itemId); statement.setInt(1, itemId);

View File

@@ -1589,7 +1589,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/ */
public static void playerEnter(L2PcInstance player) public static void playerEnter(L2PcInstance player)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ?"); PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ?");
PreparedStatement invalidQuestDataVar = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ? AND var = ?"); PreparedStatement invalidQuestDataVar = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ? AND var = ?");
PreparedStatement ps1 = con.prepareStatement("SELECT name, value FROM character_quests WHERE charId = ? AND var = ?")) PreparedStatement ps1 = con.prepareStatement("SELECT name, value FROM character_quests WHERE charId = ? AND var = ?"))
@@ -1671,7 +1671,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/ */
public static void createQuestVarInDb(QuestState qs, String var, String value) public static void createQuestVarInDb(QuestState qs, String var, String value)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?")) PreparedStatement statement = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?"))
{ {
statement.setInt(1, qs.getPlayer().getObjectId()); statement.setInt(1, qs.getPlayer().getObjectId());
@@ -1695,7 +1695,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/ */
public static void updateQuestVarInDb(QuestState qs, String var, String value) public static void updateQuestVarInDb(QuestState qs, String var, String value)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?")) PreparedStatement statement = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?"))
{ {
statement.setString(1, value); statement.setString(1, value);
@@ -1717,7 +1717,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/ */
public static void deleteQuestVarInDb(QuestState qs, String var) public static void deleteQuestVarInDb(QuestState qs, String var)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?")) PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?"))
{ {
statement.setInt(1, qs.getPlayer().getObjectId()); statement.setInt(1, qs.getPlayer().getObjectId());
@@ -1738,7 +1738,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/ */
public static void deleteQuestInDb(QuestState qs, boolean repeatable) public static void deleteQuestInDb(QuestState qs, boolean repeatable)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(repeatable ? QUEST_DELETE_FROM_CHAR_QUERY : QUEST_DELETE_FROM_CHAR_QUERY_NON_REPEATABLE_QUERY)) PreparedStatement ps = con.prepareStatement(repeatable ? QUEST_DELETE_FROM_CHAR_QUERY : QUEST_DELETE_FROM_CHAR_QUERY_NON_REPEATABLE_QUERY))
{ {
ps.setInt(1, qs.getPlayer().getObjectId()); ps.setInt(1, qs.getPlayer().getObjectId());

View File

@@ -126,7 +126,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/ */
protected void initFunctions() protected void initFunctions()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM residence_functions WHERE residenceId = ?")) PreparedStatement ps = con.prepareStatement("SELECT * FROM residence_functions WHERE residenceId = ?"))
{ {
ps.setInt(1, _residenceId); ps.setInt(1, _residenceId);
@@ -164,7 +164,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/ */
public void addFunction(ResidenceFunction func) public void addFunction(ResidenceFunction func)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO residence_functions (id, level, expiration, residenceId) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE level = ?, expiration = ?")) PreparedStatement ps = con.prepareStatement("INSERT INTO residence_functions (id, level, expiration, residenceId) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE level = ?, expiration = ?"))
{ {
ps.setInt(1, func.getId()); ps.setInt(1, func.getId());
@@ -196,7 +196,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/ */
public void removeFunction(ResidenceFunction func) public void removeFunction(ResidenceFunction func)
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ? and id = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ? and id = ?"))
{ {
ps.setInt(1, _residenceId); ps.setInt(1, _residenceId);
@@ -219,7 +219,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/ */
public void removeFunctions() public void removeFunctions()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ?")) PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ?"))
{ {
ps.setInt(1, _residenceId); ps.setInt(1, _residenceId);

View File

@@ -50,7 +50,7 @@ public class AccountVariables extends AbstractVariables
public boolean restoreMe() public boolean restoreMe()
{ {
// Restore previous variables. // Restore previous variables.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(SELECT_QUERY)) PreparedStatement st = con.prepareStatement(SELECT_QUERY))
{ {
st.setString(1, _accountName); st.setString(1, _accountName);
@@ -83,7 +83,7 @@ public class AccountVariables extends AbstractVariables
return false; return false;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Clear previous entries. // Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY)) try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
@@ -120,7 +120,7 @@ public class AccountVariables extends AbstractVariables
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Clear previous entries. // Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY)) try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

View File

@@ -50,7 +50,7 @@ public class ClanVariables extends AbstractVariables
public boolean restoreMe() public boolean restoreMe()
{ {
// Restore previous variables. // Restore previous variables.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(SELECT_QUERY)) PreparedStatement st = con.prepareStatement(SELECT_QUERY))
{ {
st.setInt(1, _objectId); st.setInt(1, _objectId);
@@ -83,7 +83,7 @@ public class ClanVariables extends AbstractVariables
return false; return false;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Clear previous entries. // Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY)) try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
@@ -120,7 +120,7 @@ public class ClanVariables extends AbstractVariables
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Clear previous entries. // Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY)) try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

View File

@@ -55,7 +55,7 @@ public class ItemVariables extends AbstractVariables
public static boolean hasVariables(int objectId) public static boolean hasVariables(int objectId)
{ {
// Restore previous variables. // Restore previous variables.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(SELECT_COUNT)) PreparedStatement st = con.prepareStatement(SELECT_COUNT))
{ {
st.setInt(1, objectId); st.setInt(1, objectId);
@@ -79,7 +79,7 @@ public class ItemVariables extends AbstractVariables
public boolean restoreMe() public boolean restoreMe()
{ {
// Restore previous variables. // Restore previous variables.
try (Connection con = DatabaseFactory.getInstance().getConnection(); try (Connection con = DatabaseFactory.getConnection();
PreparedStatement st = con.prepareStatement(SELECT_QUERY)) PreparedStatement st = con.prepareStatement(SELECT_QUERY))
{ {
st.setInt(1, _objectId); st.setInt(1, _objectId);
@@ -112,7 +112,7 @@ public class ItemVariables extends AbstractVariables
return false; return false;
} }
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Clear previous entries. // Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY)) try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
@@ -149,7 +149,7 @@ public class ItemVariables extends AbstractVariables
@Override @Override
public boolean deleteMe() public boolean deleteMe()
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) try (Connection con = DatabaseFactory.getConnection())
{ {
// Clear previous entries. // Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY)) try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

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