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

@@ -16,122 +16,68 @@
*/
package com.l2jmobius.commons.database;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zaxxer.hikari.HikariDataSource;
/**
* Database Factory implementation.
* @author Zoey76, Mobius
* @author Mobius
*/
public class DatabaseFactory
{
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)
{
Config.DATABASE_MAX_CONNECTIONS = 2;
LOGGER.warning("A minimum of 2 connections are required.");
}
_dataSource = new ComboPooledDataSource();
_dataSource.setAutoCommitOnClose(true);
_dataSource.setInitialPoolSize(10);
_dataSource.setMinPoolSize(10);
_dataSource.setMaxPoolSize(Math.max(10, Config.DATABASE_MAX_CONNECTIONS));
_dataSource.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
_dataSource.setAcquireRetryDelay(500); // 500 milliseconds wait before try to acquire connection again
_dataSource.setCheckoutTimeout(0); // 0 = wait indefinitely for new connection if pool is exhausted
_dataSource.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time cause there is
// a "long" delay on acquire connection so taking more than one connection at once will make connection pooling more effective.
// this "connection_test_table" is automatically created if not already there
_dataSource.setAutomaticTestTable("connection_test_table");
_dataSource.setTestConnectionOnCheckin(false);
// testing OnCheckin used with IdleConnectionTestPeriod is faster than testing on checkout
_dataSource.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
_dataSource.setMaxIdleTime(Config.DATABASE_MAX_IDLE_TIME); // 0 = idle connections never expire
// *THANKS* to connection testing configured above but I prefer to disconnect all connections not used for more than 1 hour
// enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
_dataSource.setMaxStatementsPerConnection(100);
_dataSource.setBreakAfterAcquireFailure(false); // never fail if any way possible setting this to true will make c3p0 "crash"
// and refuse to work till restart thus making acquire errors "FATAL" ... we don't want that it should be possible to recover
_hds.setDriverClassName(Config.DATABASE_DRIVER);
_hds.setJdbcUrl(Config.DATABASE_URL);
_hds.setUsername(Config.DATABASE_LOGIN);
_hds.setPassword(Config.DATABASE_PASSWORD);
_hds.setMaximumPoolSize(Config.DATABASE_MAX_CONNECTIONS);
_hds.setIdleTimeout(Config.DATABASE_MAX_IDLE_TIME);
// Test if connection is valid.
try
{
_dataSource.setDriverClass(Config.DATABASE_DRIVER);
_hds.getConnection().close();
LOGGER.info("Database: Initialized.");
}
catch (PropertyVetoException e)
catch (Exception e)
{
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;
while (con == null)
{
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;
}
public void close()
public static void close()
{
try
{
_dataSource.close();
_hds.close();
}
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

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

View File

@@ -587,7 +587,7 @@ public class LoginServerThread extends Thread
int chars = 0;
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=?"))
{
ps.setString(1, account);

View File

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

View File

@@ -93,7 +93,7 @@ public class Forum
private void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?"))
{
ps.setInt(1, _forumId);
@@ -114,7 +114,7 @@ public class Forum
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"))
{
ps.setInt(1, _forumId);
@@ -139,7 +139,7 @@ public class Forum
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=?"))
{
ps.setInt(1, _forumId);
@@ -217,7 +217,7 @@ public class Forum
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 (?,?,?,?,?,?,?)"))
{
ps.setInt(1, _forumId);

View File

@@ -72,7 +72,7 @@ public class Post
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 (?,?,?,?,?,?,?)"))
{
ps.setInt(1, cp.postId);
@@ -112,7 +112,7 @@ public class Post
public void deleteme(Topic 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=?"))
{
ps.setInt(1, t.getForumID());
@@ -130,7 +130,7 @@ public class Post
*/
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"))
{
ps.setInt(1, t.getForumID());
@@ -162,7 +162,7 @@ public class Post
*/
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=?"))
{
final CPost cp = getCPost(i);

View File

@@ -71,7 +71,7 @@ public class Topic
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 (?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, _id);
@@ -129,7 +129,7 @@ public class Topic
{
TopicBBSManager.getInstance().delTopic(this);
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=?"))
{
ps.setInt(1, _id);

View File

@@ -40,7 +40,7 @@ public class ForumsBBSManager extends BaseBBSManager
protected ForumsBBSManager()
{
_table = new CopyOnWriteArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
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()
{
_announcements.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
{

View File

@@ -99,7 +99,7 @@ public class CharNameTable
int id = -1;
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=?"))
{
ps.setString(1, name);
@@ -145,7 +145,7 @@ public class CharNameTable
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=?"))
{
ps.setInt(1, id);
@@ -176,7 +176,7 @@ public class CharNameTable
public synchronized boolean doesCharNameExist(String name)
{
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=?"))
{
ps.setString(1, name);
@@ -197,7 +197,7 @@ public class CharNameTable
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=?"))
{
ps.setString(1, account);
@@ -218,7 +218,7 @@ public class CharNameTable
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 = ?"))
{
ps.setInt(1, objectId);
@@ -239,7 +239,7 @@ public class CharNameTable
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 = ?"))
{
ps.setInt(1, objectId);
@@ -260,7 +260,7 @@ public class CharNameTable
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 = ?"))
{
ps.setInt(1, objectId);
@@ -281,7 +281,7 @@ public class CharNameTable
private void loadAll()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
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)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_SUMMONS))
{
@@ -87,7 +87,7 @@ public class CharSummonTable
if (Config.RESTORE_PET_ON_RECONNECT)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(INIT_PET))
{
@@ -111,7 +111,7 @@ public class CharSummonTable
return !v.isEmpty() ? v : null;
});
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
{
ps.setInt(1, activeChar.getObjectId());
@@ -181,7 +181,7 @@ public class CharSummonTable
public void restoreServitor(L2PcInstance activeChar)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
{
ps.setInt(1, activeChar.getObjectId());
@@ -229,7 +229,7 @@ public class CharSummonTable
_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))
{
ps.setInt(1, summon.getOwner().getObjectId());

View File

@@ -80,7 +80,7 @@ public class ClanTable
L2Clan clan;
// Count the clans
int clanCount = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
{
@@ -262,7 +262,7 @@ public class ClanTable
_clans.remove(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=?"))
{
@@ -361,7 +361,7 @@ public class ClanTable
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(?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, war.getAttackerClanId());
@@ -392,7 +392,7 @@ public class ClanTable
clan1.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=?"))
{
ps.setInt(1, clanId1);
@@ -407,7 +407,7 @@ public class ClanTable
private void restorewars()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement();
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);
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)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
{
final L2Crest crest = new L2Crest(_nextId.getAndIncrement(), data, crestType);
@@ -187,7 +187,7 @@ public final class CrestTable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM `crests` WHERE `crest_id` = ?"))
{
statement.setInt(1, crestId);

View File

@@ -56,7 +56,7 @@ public class OfflineTradersTable
public void storeOffliners()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE);
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS);
PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS);
@@ -173,7 +173,7 @@ public class OfflineTradersTable
{
LOGGER.info(getClass().getSimpleName() + ": Loading offline traders...");
int nTraders = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement stm = con.createStatement();
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)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER);
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER);
PreparedStatement stm3 = con.prepareStatement(SAVE_ITEMS);
@@ -453,7 +453,7 @@ public class OfflineTradersTable
{
PlayerCountManager.getInstance().decOfflineTradeCount();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_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)
{
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 (?)"))
{
ps.setString(1, name);

View File

@@ -66,7 +66,7 @@ public final class BuyListData implements IGameXmlReader
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _buyLists.size() + " BuyLists.");
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`"))
{

View File

@@ -112,7 +112,7 @@ public final class BotReportTable
*/
private void loadReportedCharData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery(SQL_LOAD_REPORTED_CHAR_DATA))
{
@@ -181,7 +181,7 @@ public final class BotReportTable
*/
public void saveReportedCharData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement st = con.createStatement();
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 (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=?"))
{
// Delete the pet in db

View File

@@ -58,7 +58,7 @@ public class SchemeBufferTable
{
int count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement st = con.prepareStatement(LOAD_SCHEMES);
ResultSet rs = st.executeQuery();
@@ -135,7 +135,7 @@ public class SchemeBufferTable
public void saveSchemes()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// Delete all entries from database.
PreparedStatement st = con.prepareStatement(DELETE_SCHEMES);

View File

@@ -77,7 +77,7 @@ public abstract class AbstractDailyMissionHandler extends ListenersContainer
public synchronized void reset()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_daily_rewards WHERE rewardId = ? AND status = ?"))
{
ps.setInt(1, _holder.getId());
@@ -118,7 +118,7 @@ public abstract class AbstractDailyMissionHandler extends ListenersContainer
protected void storePlayerEntry(DailyMissionPlayerEntry entry)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_daily_rewards (charId, rewardId, status, progress, lastCompleted) VALUES (?, ?, ?, ?, ?)"))
{
ps.setInt(1, entry.getObjectId());
@@ -145,7 +145,7 @@ public abstract class AbstractDailyMissionHandler extends ListenersContainer
return existingEntry;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_daily_rewards WHERE charId = ? AND rewardId = ?"))
{
ps.setInt(1, objectId);

View File

@@ -128,7 +128,7 @@ public abstract class IdFactory
*/
private void setAllCharacterOffline()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("UPDATE characters SET online = 0");
@@ -145,7 +145,7 @@ public abstract class IdFactory
*/
private void cleanUpDB()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement stmt = con.createStatement())
{
final long cleanupStart = System.currentTimeMillis();
@@ -253,7 +253,7 @@ public abstract class IdFactory
private void cleanUpTimeStamps()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
int cleanCount = 0;
for (String line : TIMESTAMPS_CLEAN)
@@ -279,7 +279,7 @@ public abstract class IdFactory
protected final Integer[] extractUsedObjectIDTable() throws Exception
{
final List<Integer> temp = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
String extractUsedObjectIdsQuery = "";

View File

@@ -42,7 +42,7 @@ public class StackIDFactory extends IdFactory
_curOID = 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");

View File

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

View File

@@ -198,7 +198,7 @@ public final class CastleManager implements InstanceListManager
}
}
// 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 = ?"))
{
ps.setInt(1, member.getObjectId());
@@ -215,7 +215,7 @@ public final class CastleManager implements InstanceListManager
@Override
public void loadInstances()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
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()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement stProduction = con.prepareStatement("SELECT * FROM castle_manor_production WHERE castle_id=?");
PreparedStatement stProcure = con.prepareStatement("SELECT * FROM castle_manor_procure WHERE castle_id=?"))
{
@@ -436,7 +436,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
_productionNext.put(castleId, list);
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 ips = con.prepareStatement(INSERT_PRODUCT))
{
@@ -472,7 +472,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
_procureNext.put(castleId, list);
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 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)
{
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"))
{
for (SeedProduction sp : items)
@@ -526,7 +526,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
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"))
{
for (CropProcure sp : items)
@@ -599,7 +599,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
@Override
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 is = con.prepareStatement(INSERT_PRODUCT);
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)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ?");
PreparedStatement dc = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ?"))
{

View File

@@ -91,7 +91,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MARKS, 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 = ?"))
{
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);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
{
ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_PROHIBITED_PENALTIES);

View File

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

View File

@@ -79,7 +79,7 @@ public final class CommissionManager
protected CommissionManager()
{
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))
{
@@ -245,7 +245,7 @@ public final class CommissionManager
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS))
{
final Instant startTime = Instant.now();
@@ -398,7 +398,7 @@ public final class CommissionManager
*/
private boolean deleteItemFromDB(long commissionId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM))
{
ps.setLong(1, commissionId);

View File

@@ -142,7 +142,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
private void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
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()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
{
// TODO: See comments below...
@@ -338,7 +338,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
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 = ?"))
{
ps.setInt(1, itemId);

View File

@@ -85,7 +85,7 @@ public class DBSpawnManager
_storedInfo.clear();
_schedules.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM npc_respawns");
ResultSet rset = statement.executeQuery())
{
@@ -275,7 +275,7 @@ public class DBSpawnManager
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(?, ?, ?, ?, ?, ?, ?, ?)"))
{
statement.setInt(1, spawn.getId());
@@ -331,7 +331,7 @@ public class DBSpawnManager
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(?, ?, ?, ?, ?, ?, ?, ?)"))
{
statement.setInt(1, spawn.getId());
@@ -380,7 +380,7 @@ public class DBSpawnManager
if (updateDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM npc_respawns WHERE id = ?"))
{
ps.setInt(1, npcId);
@@ -401,7 +401,7 @@ public class DBSpawnManager
*/
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 = ?"))
{
for (Integer npcId : _storedInfo.keySet())

View File

@@ -120,7 +120,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 = ?"))
{
@@ -150,7 +150,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
private void resetExtendDrop()
{
// 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 = ?"))
{
ps.setString(1, PlayerVariables.EXTEND_DROP);
@@ -173,7 +173,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
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());
for (SkillHolder skill : dailySkills)
@@ -200,7 +200,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
}
// 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 = ?"))
{
ps.setInt(1, 0);
@@ -225,7 +225,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
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"))
{
@@ -258,7 +258,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
if (Config.TRAINING_CAMP_ENABLE)
{
// 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 = ?"))
{
ps.setString(1, "TRAINING_CAMP_DURATION");

View File

@@ -46,7 +46,7 @@ public class FactionManager
private void loadAll()
{
_playerFactions.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
{
@@ -75,7 +75,7 @@ public class FactionManager
return factionId;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
{
ps.setInt(1, id);

View File

@@ -121,7 +121,7 @@ public final class FortManager implements InstanceListManager
@Override
public void loadInstances()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id FROM fort ORDER BY id"))
{

View File

@@ -86,7 +86,7 @@ public final class FortSiegeManager
}
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=?"))
{
ps.setInt(1, clan.getId());

View File

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

View File

@@ -62,7 +62,7 @@ public final class GrandBossManager implements IStorable
private void init()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
{
@@ -154,7 +154,7 @@ public final class GrandBossManager implements IStorable
@Override
public boolean storeMe()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
for (Entry<Integer, StatsSet> e : _storedInfo.entrySet())
{
@@ -206,7 +206,7 @@ public final class GrandBossManager implements IStorable
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 StatsSet info = _storedInfo.get(bossId);

View File

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

View File

@@ -55,7 +55,7 @@ public final class ItemAuctionManager implements IGameXmlReader
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement();
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)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
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";
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(str))
{
ps.setLong(1, System.currentTimeMillis());
@@ -93,7 +93,7 @@ public final class ItemsOnGroundManager implements Runnable
}
// Add items to world
try (Connection con = 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"))
{
int count = 0;
@@ -178,7 +178,7 @@ public final class ItemsOnGroundManager implements Runnable
public void emptyTable()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("DELETE FROM itemsonground");
@@ -204,7 +204,7 @@ public final class ItemsOnGroundManager implements Runnable
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(?,?,?,?,?,?,?,?,?)"))
{
for (L2ItemInstance item : _items)

View File

@@ -57,7 +57,7 @@ public final class MailManager
private void load()
{
int count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement ps = con.createStatement();
ResultSet rs = ps.executeQuery("SELECT * FROM messages ORDER BY expiration"))
{
@@ -192,7 +192,7 @@ public final class MailManager
public void sendMessage(Message msg)
{
_messages.put(msg.getId(), msg);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = Message.getStatement(msg, con))
{
ps.execute();
@@ -214,7 +214,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@@ -228,7 +228,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@@ -242,7 +242,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@@ -256,7 +256,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);
@@ -270,7 +270,7 @@ public final class MailManager
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 = ?"))
{
ps.setInt(1, msgId);

View File

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

View File

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

View File

@@ -56,7 +56,7 @@ public final class PunishmentManager
int expired = 0;
// Load punishments.
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement st = con.createStatement();
ResultSet rset = st.executeQuery("SELECT * FROM punishments"))
{

View File

@@ -57,7 +57,7 @@ public final class SiegeGuardManager
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"))
{
while (rs.next())
@@ -158,7 +158,7 @@ public final class SiegeGuardManager
final SiegeGuardHolder holder = getSiegeGuardByItem(castle.getResidenceId(), itemId);
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 (?, ?, ?, ?, ?, ?, ?, ?)"))
{
statement.setInt(1, castle.getResidenceId());
@@ -249,7 +249,7 @@ public final class SiegeGuardManager
*/
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 = ?"))
{
ps.setInt(1, castle.getResidenceId());
@@ -283,7 +283,7 @@ public final class SiegeGuardManager
*/
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"))
{
ps.setInt(1, npcId);
@@ -304,7 +304,7 @@ public final class SiegeGuardManager
*/
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"))
{
ps.setInt(1, castle.getResidenceId());

View File

@@ -88,7 +88,7 @@ public final class SiegeManager
}
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=?"))
{
statement.setInt(1, clan.getId());
@@ -275,7 +275,7 @@ public final class SiegeManager
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=?"))
{
ps.setInt(1, castleId);

View File

@@ -71,7 +71,7 @@ public class BlockList
private static List<Integer> loadList(int ObjId)
{
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"))
{
statement.setInt(1, ObjId);
@@ -98,7 +98,7 @@ public class BlockList
private void updateInDB(int targetId, boolean state)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (state) // add
{

View File

@@ -136,7 +136,7 @@ public class CursedWeapon implements INamable
// Remove from Db
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 ps = con.prepareStatement("UPDATE characters SET reputation=?, pkkills=? WHERE charId=?"))
{
@@ -471,7 +471,7 @@ public class CursedWeapon implements INamable
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 ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerReputation, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
{

View File

@@ -266,7 +266,7 @@ public class L2Clan implements IIdentifiable, INamable
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
{
ps.setInt(1, 0);
@@ -306,7 +306,7 @@ public class L2Clan implements IIdentifiable, INamable
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
{
ps.setInt(1, EnumIntBitmask.getAllBitmask(ClanPrivilege.class));
@@ -883,7 +883,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, _bloodAllianceCount);
@@ -927,7 +927,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, _bloodOathCount);
@@ -943,7 +943,7 @@ public class L2Clan implements IIdentifiable, INamable
public void updateInDB()
{
// 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=?"))
{
ps.setInt(1, _reputationScore);
@@ -978,7 +978,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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=?"))
{
ps.setInt(1, getLeaderId());
@@ -1016,7 +1016,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void store()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
{
ps.setInt(1, _clanId);
@@ -1047,7 +1047,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
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 ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
@@ -1072,7 +1072,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
{
ps.setInt(1, _clanId);
@@ -1147,7 +1147,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, _clanId);
@@ -1178,7 +1178,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, _clanId);
@@ -1237,7 +1237,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -1360,7 +1360,7 @@ public class L2Clan implements IIdentifiable, INamable
}
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (oldSkill != null)
{
@@ -1770,7 +1770,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
// Retrieve all subpledges of this clan from the database
@@ -1870,7 +1870,7 @@ public class L2Clan implements IIdentifiable, INamable
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 (?,?,?,?)"))
{
ps.setInt(1, _clanId);
@@ -1953,7 +1953,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, getSubPledge(pledgeType).getLeaderId());
@@ -1970,7 +1970,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -2019,7 +2019,7 @@ public class L2Clan implements IIdentifiable, INamable
{
_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 = ?"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -2055,7 +2055,7 @@ public class L2Clan implements IIdentifiable, INamable
{
_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 (?,?,?,?)"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -2174,7 +2174,7 @@ public class L2Clan implements IIdentifiable, INamable
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=?"))
{
ps.setInt(1, id);
@@ -2623,7 +2623,7 @@ public class L2Clan implements IIdentifiable, INamable
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 = ?"))
{
ps.setInt(1, level);
@@ -2669,7 +2669,7 @@ public class L2Clan implements IIdentifiable, INamable
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 = ?"))
{
ps.setInt(1, crestId);
@@ -2706,7 +2706,7 @@ public class L2Clan implements IIdentifiable, INamable
allyId = _allyId;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(sqlStatement))
{
ps.setInt(1, crestId);
@@ -2752,7 +2752,7 @@ public class L2Clan implements IIdentifiable, INamable
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 = ?"))
{
ps.setInt(1, crestId);

View File

@@ -244,7 +244,7 @@ public class L2ClanMember
*/
public void updatePledgeType()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET subpledge=? WHERE charId=?"))
{
ps.setLong(1, _pledgeType);
@@ -289,7 +289,7 @@ public class L2ClanMember
*/
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=?"))
{
ps.setLong(1, _powerGrade);
@@ -800,7 +800,7 @@ public class L2ClanMember
*/
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=?"))
{
ps.setInt(1, apprentice);

View File

@@ -58,7 +58,7 @@ public class L2ContactList
{
_contacts.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
{
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))
{
statement.setInt(1, activeChar.getObjectId());
@@ -161,7 +161,7 @@ public class L2ContactList
_contacts.remove(name);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
{
statement.setInt(1, activeChar.getObjectId());

View File

@@ -49,7 +49,7 @@ public class L2Mentee
final L2PcInstance player = getPlayerInstance();
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 = ?"))
{
statement.setInt(1, _objectId);

View File

@@ -124,7 +124,7 @@ public class MacroList implements IRestorable
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(?,?,?,?,?,?,?)"))
{
ps.setInt(1, _owner.getObjectId());
@@ -160,7 +160,7 @@ public class MacroList implements IRestorable
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=?"))
{
ps.setInt(1, _owner.getObjectId());
@@ -177,7 +177,7 @@ public class MacroList implements IRestorable
public boolean restoreMe()
{
_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=?"))
{
ps.setInt(1, _owner.getObjectId());

View File

@@ -85,7 +85,7 @@ public class ShortCuts implements IRestorable
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(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, _owner.getObjectId());
@@ -154,7 +154,7 @@ public class ShortCuts implements IRestorable
*/
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=?"))
{
statement.setInt(1, _owner.getObjectId());
@@ -173,7 +173,7 @@ public class ShortCuts implements IRestorable
public boolean restoreMe()
{
_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=?"))
{
statement.setInt(1, _owner.getObjectId());

View File

@@ -1325,7 +1325,7 @@ public final class L2PcInstance extends L2Playable
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(?,?,?,?)"))
{
statement.setInt(1, getObjectId());
@@ -1342,7 +1342,7 @@ public final class L2PcInstance extends L2Playable
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=?"))
{
statement.setInt(1, getObjectId());
@@ -6306,7 +6306,7 @@ public final class L2PcInstance extends L2Playable
if (updateInDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER_ACCESS))
{
ps.setInt(1, accessLevel.getLevel());
@@ -6425,7 +6425,7 @@ public final class L2PcInstance extends L2Playable
*/
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=?"))
{
statement.setInt(1, isOnlineInt());
@@ -6445,7 +6445,7 @@ public final class L2PcInstance extends L2Playable
*/
private boolean createDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_CHARACTER))
{
statement.setString(1, _accountName);
@@ -6509,7 +6509,7 @@ public final class L2PcInstance extends L2Playable
double currentCp = 0;
double currentHp = 0;
double currentMp = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER))
{
// Retrieve the L2PcInstance from the characters table of the database
@@ -6870,7 +6870,7 @@ public final class L2PcInstance extends L2Playable
*/
private static boolean restoreSubClassData(L2PcInstance player)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
{
statement.setInt(1, player.getObjectId());
@@ -6961,7 +6961,7 @@ public final class L2PcInstance extends L2Playable
private void restoreRecipeBook(boolean loadCommon)
{
final String sql = loadCommon ? "SELECT id, type, classIndex FROM character_recipebook WHERE charId=?" : "SELECT id FROM character_recipebook WHERE charId=? AND classIndex=? AND type = 1";
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(sql))
{
statement.setInt(1, getObjectId());
@@ -7014,7 +7014,7 @@ public final class L2PcInstance extends L2Playable
private void loadPremiumItemList()
{
final String sql = "SELECT itemNum, itemId, itemCount, itemSender FROM character_premium_items WHERE charId=?";
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(sql))
{
statement.setInt(1, getObjectId());
@@ -7038,7 +7038,7 @@ public final class L2PcInstance extends L2Playable
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=? "))
{
statement.setLong(1, newcount);
@@ -7054,7 +7054,7 @@ public final class L2PcInstance extends L2Playable
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=? "))
{
statement.setInt(1, getObjectId());
@@ -7107,7 +7107,7 @@ public final class L2PcInstance extends L2Playable
final long exp = getStat().getBaseExp();
final int level = getStat().getBaseLevel();
final long sp = getStat().getBaseSp();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER))
{
statement.setInt(1, level);
@@ -7192,7 +7192,7 @@ public final class L2PcInstance extends L2Playable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
{
for (SubClass subClass : getSubClasses().values())
@@ -7223,7 +7223,7 @@ public final class L2PcInstance extends L2Playable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE);
PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE))
{
@@ -7343,7 +7343,7 @@ public final class L2PcInstance extends L2Playable
private void storeItemReuseDelay()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE))
{
@@ -7460,7 +7460,7 @@ public final class L2PcInstance extends L2Playable
final Skill oldSkill = super.removeSkill(skill, true);
if (oldSkill != null)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
{
// Remove or update a L2PcInstance skill from the character_skills table of the database
@@ -7503,7 +7503,7 @@ public final class L2PcInstance extends L2Playable
private void storeSkill(Skill newSkill, Skill oldSkill, int newClassIndex)
{
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if ((oldSkill != null) && (newSkill != null))
{
@@ -7553,7 +7553,7 @@ public final class L2PcInstance extends L2Playable
}
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))
{
con.setAutoCommit(false);
@@ -7580,7 +7580,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreSkills()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -7632,7 +7632,7 @@ public final class L2PcInstance extends L2Playable
@Override
public void restoreEffects()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
{
statement.setInt(1, getObjectId());
@@ -7689,7 +7689,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreItemReuse()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE))
{
@@ -7760,7 +7760,7 @@ public final class L2PcInstance extends L2Playable
_henna[i - 1] = null;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS))
{
statement.setInt(1, getObjectId());
@@ -7867,7 +7867,7 @@ public final class L2PcInstance extends L2Playable
_henna[slot - 1] = null;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA))
{
statement.setInt(1, getObjectId());
@@ -7948,7 +7948,7 @@ public final class L2PcInstance extends L2Playable
// Calculate Henna modifiers of this L2PcInstance
recalcHennaStats();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA))
{
statement.setInt(1, getObjectId());
@@ -9572,7 +9572,7 @@ public final class L2PcInstance extends L2Playable
newClass.setLevel(Config.BASE_DUALCLASS_LEVEL);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS))
{
// Store the basic info about this new sub-class.
@@ -9672,7 +9672,7 @@ public final class L2PcInstance extends L2Playable
// Remove after stats are recalculated.
getSubClasses().remove(classIndex);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS);
PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE);
@@ -11816,7 +11816,7 @@ public final class L2PcInstance extends L2Playable
{
String req;
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))
{
statement.setInt(1, _curFeed);
@@ -11943,7 +11943,7 @@ public final class L2PcInstance extends L2Playable
bookmark.setTag(tag);
bookmark.setName(name);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK))
{
statement.setInt(1, icon);
@@ -11966,7 +11966,7 @@ public final class L2PcInstance extends L2Playable
{
if (_tpbookmarks.remove(id) != null)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK))
{
statement.setInt(1, getObjectId());
@@ -12109,7 +12109,7 @@ public final class L2PcInstance extends L2Playable
sm.addItemName(20033);
sendPacket(sm);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK))
{
statement.setInt(1, getObjectId());
@@ -12131,7 +12131,7 @@ public final class L2PcInstance extends L2Playable
public void restoreTeleportBookmark()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK))
{
statement.setInt(1, getObjectId());
@@ -12343,7 +12343,7 @@ public final class L2PcInstance extends L2Playable
_friendList.clear();
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))
{
statement.setInt(1, getObjectId());
@@ -12433,7 +12433,7 @@ public final class L2PcInstance extends L2Playable
{
if (hasManufactureShop())
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
{
@@ -12471,7 +12471,7 @@ public final class L2PcInstance extends L2Playable
_manufactureItems.clear();
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
{
statement.setInt(1, getObjectId());
@@ -12889,7 +12889,7 @@ public final class L2PcInstance extends L2Playable
*/
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;"))
{
statement.setInt(1, getObjectId());
@@ -12929,7 +12929,7 @@ public final class L2PcInstance extends L2Playable
*/
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 = ?"))
{
statement.setInt(1, getObjectId());
@@ -12953,7 +12953,7 @@ public final class L2PcInstance extends L2Playable
*/
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 (?,?,?,?)"))
{
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
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
{
statement.setInt(1, _controlObjectId);
@@ -846,7 +846,7 @@ public class L2PetInstance extends L2Summon
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=?"))
{
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 = ?";
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(req))
{
statement.setString(1, getName());
@@ -992,7 +992,7 @@ public class L2PetInstance extends L2Summon
// Clear list for overwrite
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 ps2 = con.prepareStatement(ADD_SKILL_SAVE))
{
@@ -1067,7 +1067,7 @@ public class L2PetInstance extends L2Summon
@Override
public void restoreEffects()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(RESTORE_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();
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
{
// Delete all current stored effects for summon to avoid dupe
@@ -389,7 +389,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
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()))
{

View File

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

View File

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

View File

@@ -157,7 +157,7 @@ public final class Product
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` = ?"))
{
statement.setInt(1, _buyListId);

View File

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

View File

@@ -219,7 +219,7 @@ public final class Castle extends AbstractResidence
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 (?,?,?,?,?,?)"))
{
ps.setInt(1, getResidenceId());
@@ -361,7 +361,7 @@ public final class Castle extends AbstractResidence
_treasury += amount;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
{
ps.setLong(1, _treasury);
@@ -644,7 +644,7 @@ public final class Castle extends AbstractResidence
@Override
protected void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
{
@@ -690,7 +690,7 @@ public final class Castle extends AbstractResidence
/** Load All Functions */
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 = ?"))
{
ps.setInt(1, getResidenceId());
@@ -715,7 +715,7 @@ public final class Castle extends AbstractResidence
public void removeFunction(int 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=?"))
{
ps.setInt(1, getResidenceId());
@@ -787,7 +787,7 @@ public final class Castle extends AbstractResidence
// This method loads castle door upgrade data from database
private void loadDoorUpgrade()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
{
ps.setInt(1, getResidenceId());
@@ -813,7 +813,7 @@ public final class Castle extends AbstractResidence
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=?"))
{
ps.setInt(1, getResidenceId());
@@ -838,7 +838,7 @@ public final class Castle extends AbstractResidence
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 (?,?,?)"))
{
ps.setInt(1, doorId);
@@ -865,7 +865,7 @@ public final class Castle extends AbstractResidence
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.
try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?"))
@@ -1033,7 +1033,7 @@ public final class Castle extends AbstractResidence
public void updateShowNpcCrest()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
{
ps.setString(1, String.valueOf(_showNpcCrest));
@@ -1077,7 +1077,7 @@ public final class Castle extends AbstractResidence
{
_ticketBuyCount = count;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
{
ps.setInt(1, _ticketBuyCount);
@@ -1100,7 +1100,7 @@ public final class Castle extends AbstractResidence
{
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 (?,?,?)"))
{
ps.setInt(1, getResidenceId());
@@ -1127,7 +1127,7 @@ public final class Castle extends AbstractResidence
ts.setUpgradeLevel(0);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
{
ps.setInt(1, getResidenceId());
@@ -1208,7 +1208,7 @@ public final class Castle extends AbstractResidence
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
{
ps.setString(1, side.toString());

View File

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

View File

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

View File

@@ -214,7 +214,7 @@ public final class Fort extends AbstractResidence
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 (?,?,?,?,?,?)"))
{
ps.setInt(1, getResidenceId());
@@ -487,7 +487,7 @@ public final class Fort extends AbstractResidence
public void saveFortVariables()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
{
ps.setInt(1, _supplyLvL);
@@ -552,7 +552,7 @@ public final class Fort extends AbstractResidence
@Override
protected void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
{
ps.setInt(1, getResidenceId());
@@ -613,7 +613,7 @@ public final class Fort extends AbstractResidence
/** Load All Functions */
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 = ?"))
{
ps.setInt(1, getResidenceId());
@@ -638,7 +638,7 @@ public final class Fort extends AbstractResidence
public void removeFunction(int 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=?"))
{
ps.setInt(1, getResidenceId());
@@ -730,7 +730,7 @@ public final class Fort extends AbstractResidence
// This method loads fort door upgrade data from database
private void loadDoorUpgrade()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
{
ps.setInt(1, getResidenceId());
@@ -750,7 +750,7 @@ public final class Fort extends AbstractResidence
private void removeDoorUpgrade()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
{
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)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
{
ps.setInt(1, doorId);
@@ -793,7 +793,7 @@ public final class Fort extends AbstractResidence
_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 = ?"))
{
ps.setInt(1, clanId);
@@ -998,7 +998,7 @@ public final class Fort extends AbstractResidence
{
_state = state;
_castleId = castleId;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
{
ps.setInt(1, _state);
@@ -1130,7 +1130,7 @@ public final class Fort extends AbstractResidence
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 = ?"))
{
ps.setInt(1, getResidenceId());
@@ -1159,7 +1159,7 @@ public final class Fort extends AbstractResidence
private void initSiegeNpcs()
{
_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"))
{
ps.setInt(1, getResidenceId());
@@ -1186,7 +1186,7 @@ public final class Fort extends AbstractResidence
private void initNpcCommanders()
{
_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"))
{
ps.setInt(1, getResidenceId());
@@ -1216,7 +1216,7 @@ public final class Fort extends AbstractResidence
_specialEnvoys.clear();
_envoyCastles.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"))
{
ps.setInt(1, getResidenceId());

View File

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

View File

@@ -114,7 +114,7 @@ public class Hero
_herodiary.clear();
_heroMessage.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s1 = con.createStatement();
ResultSet rset = s1.executeQuery(GET_HEROES);
PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
@@ -211,7 +211,7 @@ public class Hero
*/
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=?"))
{
statement.setInt(1, charId);
@@ -233,7 +233,7 @@ public class Hero
{
final List<StatsSet> _diary = new CopyOnWriteArrayList<>();
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"))
{
statement.setInt(1, charId);
@@ -300,7 +300,7 @@ public class Hero
int _losses = 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"))
{
statement.setInt(1, charId);
@@ -699,7 +699,7 @@ public class Hero
public void updateHeroes(boolean setDefault)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (setDefault)
{
@@ -841,7 +841,7 @@ public class Hero
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(?,?,?,?)"))
{
statement.setInt(1, charId);
@@ -877,7 +877,7 @@ public class Hero
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{
statement.setString(1, _heroMessage.get(charId));
@@ -892,7 +892,7 @@ public class Hero
private void deleteItemsInDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_ITEMS))
{
statement.execute();

View File

@@ -760,7 +760,7 @@ public class Siege implements Siegable
/** Clear all registered siege clans from database for castle */
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=?"))
{
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 */
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"))
{
statement.setInt(1, _castle.getResidenceId());
@@ -972,7 +972,7 @@ public class Siege implements Siegable
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=?"))
{
statement.setInt(1, _castle.getResidenceId());
@@ -1238,7 +1238,7 @@ public class Siege implements Siegable
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=?"))
{
getAttackerClans().clear();
@@ -1349,7 +1349,7 @@ public class Siege implements Siegable
_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 = ?"))
{
statement.setLong(1, _castle.getSiegeDate().getTimeInMillis());
@@ -1378,7 +1378,7 @@ public class Siege implements Siegable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
{

View File

@@ -138,7 +138,7 @@ public class EventScheduler
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 = ?"))
{
ps.setString(1, _eventManager.getName());

View File

@@ -52,7 +52,7 @@ public class HaventRunConditionalScheduler implements IConditionalEventScheduler
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 = ?"))
{
ps.setString(1, _eventManager.getName());

View File

@@ -815,7 +815,7 @@ public final class Instance implements IIdentifiable, INamable
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 (?,?,?)"))
{
// Save to database

View File

@@ -191,7 +191,7 @@ public final class ItemAuction
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=?"))
{
statement.setInt(1, _auctionId);
@@ -225,7 +225,7 @@ public final class ItemAuction
final void updatePlayerBidInternal(ItemAuctionBid bid, boolean delete)
{
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))
{
ps.setInt(1, _auctionId);

View File

@@ -161,7 +161,7 @@ public final class ItemAuctionInstance
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))
{
ps.setInt(1, _instanceId);
@@ -533,7 +533,7 @@ public final class ItemAuctionInstance
private ItemAuction loadAuction(int auctionId) throws SQLException
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
int auctionItemId = 0;
long startingTime = 0;

View File

@@ -1813,7 +1813,7 @@ public abstract class Inventory extends ItemContainer
@Override
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"))
{
ps.setInt(1, getOwnerId());

View File

@@ -673,7 +673,7 @@ public abstract class ItemContainer
*/
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=?)"))
{
ps.setInt(1, getOwnerId());

View File

@@ -112,7 +112,7 @@ public class Mail extends ItemContainer
@Override
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=?"))
{
statement.setInt(1, _ownerId);

View File

@@ -738,7 +738,7 @@ public class PcInventory extends Inventory
public static int[][] restoreVisibleInventory(int objectId)
{
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'"))
{
statement2.setInt(1, objectId);

View File

@@ -983,7 +983,7 @@ public final class L2ItemInstance extends L2Object
final VariationInstance augment = _augmentation;
_augmentation = null;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId = ?"))
{
ps.setInt(1, getObjectId());
@@ -1000,7 +1000,7 @@ public final class L2ItemInstance extends L2Object
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 ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
{
@@ -1041,7 +1041,7 @@ public final class L2ItemInstance extends L2Object
public void updateItemOptions()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
updateItemOptions(con);
}
@@ -1069,7 +1069,7 @@ public final class L2ItemInstance extends L2Object
public void updateItemElementals()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
updateItemElements(con);
}
@@ -1231,7 +1231,7 @@ public final class L2ItemInstance extends L2Object
_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 = ?"))
{
ps.setInt(1, getObjectId());
@@ -1256,7 +1256,7 @@ public final class L2ItemInstance extends L2Object
_elementals.clear();
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ?"))
{
ps.setInt(1, getObjectId());
@@ -1588,7 +1588,7 @@ public final class L2ItemInstance extends L2Object
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 = ?"))
{
ps.setInt(1, _ownerId);
@@ -1621,7 +1621,7 @@ public final class L2ItemInstance extends L2Object
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 (?,?,?,?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, _ownerId);
@@ -1669,7 +1669,7 @@ public final class L2ItemInstance extends L2Object
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?"))
{
@@ -2183,7 +2183,7 @@ public final class L2ItemInstance extends L2Object
private void removeSpecialAbility(EnsoulOption option)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_special_abilities WHERE objectId = ? AND optionId = ?"))
{
ps.setInt(1, getObjectId());
@@ -2237,7 +2237,7 @@ public final class L2ItemInstance extends L2Object
private void restoreSpecialAbilities()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM item_special_abilities WHERE objectId = ? ORDER BY position"))
{
ps.setInt(1, getObjectId());
@@ -2264,7 +2264,7 @@ public final class L2ItemInstance extends L2Object
public void updateSpecialAbilities()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
updateSpecialAbilities(con);
}

View File

@@ -142,7 +142,7 @@ public class Olympiad extends ListenersContainer
{
_nobles.clear();
boolean loaded = false;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA);
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);
ResultSet rset = statement.executeQuery())
{
@@ -295,7 +295,7 @@ public class Olympiad extends ListenersContainer
{
_noblesRank.clear();
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);
ResultSet rset = statement.executeQuery())
{
@@ -806,7 +806,7 @@ public class Olympiad extends ListenersContainer
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
{
@@ -878,7 +878,7 @@ public class Olympiad extends ListenersContainer
{
saveNobleData();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA))
{
statement.setInt(1, _currentCycle);
@@ -919,7 +919,7 @@ public class Olympiad extends ListenersContainer
protected void updateMonthlyData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
PreparedStatement ps2 = con.prepareStatement(OLYMPIAD_MONTH_CREATE))
{
@@ -963,7 +963,7 @@ public class Olympiad extends ListenersContainer
final List<StatsSet> heroesToBe = new LinkedList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
{
StatsSet hero;
@@ -998,7 +998,7 @@ public class Olympiad extends ListenersContainer
{
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);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
ps.setInt(1, classId);
@@ -1108,7 +1108,7 @@ public class Olympiad extends ListenersContainer
public int getLastNobleOlympiadPoints(int objId)
{
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 = ?"))
{
ps.setInt(1, objId);
@@ -1252,7 +1252,7 @@ public class Olympiad extends ListenersContainer
protected void deleteNobles()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL))
{
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)
{
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(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());

View File

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

View File

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

View File

@@ -1568,7 +1568,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
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 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 = ?"))
@@ -1650,7 +1650,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
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=?"))
{
statement.setInt(1, qs.getPlayer().getObjectId());
@@ -1674,7 +1674,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
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 = ?"))
{
statement.setString(1, value);
@@ -1696,7 +1696,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
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=?"))
{
statement.setInt(1, qs.getPlayer().getObjectId());
@@ -1717,7 +1717,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
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))
{
ps.setInt(1, qs.getPlayer().getObjectId());

View File

@@ -126,7 +126,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/
protected void initFunctions()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM residence_functions WHERE residenceId = ?"))
{
ps.setInt(1, _residenceId);
@@ -164,7 +164,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/
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 = ?"))
{
ps.setInt(1, func.getId());
@@ -196,7 +196,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/
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 = ?"))
{
ps.setInt(1, _residenceId);
@@ -219,7 +219,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
*/
public void removeFunctions()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ?"))
{
ps.setInt(1, _residenceId);

View File

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

View File

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

View File

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

View File

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

View File

@@ -329,7 +329,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET deletetime=? WHERE charId=?"))
{
ps2.setLong(1, System.currentTimeMillis() + (Config.DELETE_DAYS * 86400000)); // 24*60*60*1000 = 86400000
@@ -354,7 +354,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET deletetime=0 WHERE charId=?"))
{
statement.setInt(1, objectId);
@@ -377,7 +377,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
CharNameTable.getInstance().removeName(objid);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_contacts WHERE charId=? OR contactId=?"))
{

View File

@@ -164,7 +164,7 @@ public final class RequestDestroyItem implements IClientIncomingPacket
pet.unSummon(activeChar);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
{
statement.setInt(1, _objectId);

View File

@@ -62,7 +62,7 @@ public class RequestPetitionFeedback implements IClientIncomingPacket
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_FEEDBACK))
{
statement.setString(1, player.getName());

View File

@@ -73,7 +73,7 @@ public final class RequestAnswerFriendInvite implements IClientIncomingPacket
if (_response == 1)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId) VALUES (?, ?), (?, ?)"))
{
statement.setInt(1, requestor.getObjectId());

View File

@@ -75,7 +75,7 @@ public final class RequestFriendDel implements IClientIncomingPacket
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE (charId=? AND friendId=?) OR (charId=? AND friendId=?)"))
{
statement.setInt(1, activeChar.getObjectId());

View File

@@ -74,7 +74,7 @@ public class ConfirmMenteeAdd implements IClientIncomingPacket
}
else if (validate(mentor, mentee))
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_mentees (charId, mentorId) VALUES (?, ?)"))
{
statement.setInt(1, mentee.getObjectId());

View File

@@ -226,7 +226,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
CharSelectInfoPackage charInfopackage;
final List<CharSelectInfoPackage> characterList = new LinkedList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM characters WHERE account_name=? ORDER BY createDate"))
{
statement.setString(1, loginName);
@@ -259,7 +259,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
private static void loadCharacterSubclassInfo(CharSelectInfoPackage charInfopackage, int ObjectId, int activeClassId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT exp, sp, level, vitality_points FROM character_subclasses WHERE charId=? AND class_id=? ORDER BY charId"))
{
statement.setInt(1, ObjectId);
@@ -369,7 +369,7 @@ public class CharSelectionInfo implements IClientOutgoingPacket
if (weaponObjId > 0)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT mineralId,option1,option2 FROM item_variations WHERE itemId=?"))
{
statement.setInt(1, weaponObjId);

View File

@@ -70,7 +70,7 @@ public class FriendList implements IClientOutgoingPacket
if (player1 == null)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT char_name, online, classid, level FROM characters WHERE charId = ?"))
{
statement.setInt(1, objId);

View File

@@ -72,7 +72,7 @@ public class SecondaryPasswordAuth
private void loadPassword()
{
String var, value = null;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(SELECT_PASSWORD))
{
statement.setString(1, _activeClient.getAccountName());
@@ -117,7 +117,7 @@ public class SecondaryPasswordAuth
password = cryptPassword(password);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_PASSWORD))
{
statement.setString(1, _activeClient.getAccountName());
@@ -136,7 +136,7 @@ public class SecondaryPasswordAuth
public boolean insertWrongAttempt(int attempts)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_ATTEMPT))
{
statement.setString(1, _activeClient.getAccountName());
@@ -175,7 +175,7 @@ public class SecondaryPasswordAuth
newPassword = cryptPassword(newPassword);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_PASSWORD))
{
statement.setString(1, newPassword);

View File

@@ -95,7 +95,7 @@ public final class TaskManager
{
task.onTimeElapsed(this);
lastActivation = System.currentTimeMillis();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(SQL_STATEMENTS[1]))
{
statement.setLong(1, lastActivation);
@@ -182,7 +182,7 @@ public final class TaskManager
private void startAllTasks()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(SQL_STATEMENTS[0]);
ResultSet rset = statement.executeQuery())
{
@@ -314,7 +314,7 @@ public final class TaskManager
private static boolean addUniqueTask(String task, TaskTypes type, String param1, String param2, String param3, long lastActivation)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement(SQL_STATEMENTS[2]))
{
ps1.setString(1, task);
@@ -350,7 +350,7 @@ public final class TaskManager
private static boolean addTask(String task, TaskTypes type, String param1, String param2, String param3, long lastActivation)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(SQL_STATEMENTS[3]))
{
statement.setString(1, task);

View File

@@ -76,7 +76,7 @@ public class TaskBirthday extends Task
private void checkBirthday(int year, int month, int day)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(QUERY))
{
statement.setString(1, "%-" + getNum(month + 1) + "-" + getNum(day));

View File

@@ -248,7 +248,7 @@ public final class Evolve
}
// pet control item no longer exists, delete the pet from the db
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
{
ps.setInt(1, removedItem.getObjectId());

View File

@@ -115,7 +115,7 @@ public final class GameServerTable implements IGameXmlReader
*/
private void loadRegisteredGameServers()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement ps = con.createStatement();
ResultSet rs = ps.executeQuery("SELECT * FROM gameservers"))
{
@@ -222,7 +222,7 @@ public final class GameServerTable implements IGameXmlReader
public void registerServerOnDB(byte[] hexId, int id, String externalHost)
{
register(id, new GameServerInfo(id, hexId));
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO gameservers (hexid,server_id,host) values (?,?,?)"))
{
ps.setString(1, hexToString(hexId));

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