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

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

View File

@@ -584,7 +584,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

@@ -850,7 +850,7 @@ public class SevenSigns
*/
protected void restoreSevenSignsData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
try (Statement s = con.createStatement();
ResultSet rs = s.executeQuery(LOAD_DATA))
@@ -917,7 +917,7 @@ public class SevenSigns
*/
public void saveSevenSignsData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_PLAYER))
{
for (StatsSet sevenDat : _signsPlayerData.values())
@@ -948,7 +948,7 @@ public class SevenSigns
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_PLAYER))
{
ps.setString(1, sevenDat.getString("cabal"));
@@ -969,7 +969,7 @@ public class SevenSigns
public final void saveSevenSignsStatus()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_STATUS))
{
ps.setInt(1, _currentCycle);
@@ -1056,7 +1056,7 @@ public class SevenSigns
_signsPlayerData.put(objectId, currPlayerData);
// Update data in database, as we have a new player signing up.
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_PLAYER))
{
ps.setInt(1, objectId);

View File

@@ -941,7 +941,7 @@ public class SevenSignsFestival implements SpawnListener
*/
protected void restoreFestivalData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT festivalId, cabal, cycle, date, score, members FROM seven_signs_festival"))
{
@@ -989,7 +989,7 @@ public class SevenSignsFestival implements SpawnListener
query.append(' ');
query.append("FROM seven_signs_status WHERE id=0");
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(query.toString()))
{
@@ -1015,7 +1015,7 @@ public class SevenSignsFestival implements SpawnListener
*/
public void saveFestivalData(boolean updateSettings)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement psInsert = con.prepareStatement("REPLACE INTO seven_signs_festival (festivalId, cabal, cycle, date, score, members) VALUES (?,?,?,?,?,?)"))
{
for (Map<Integer, StatsSet> currCycleData : _festivalData.values())
@@ -1118,7 +1118,7 @@ public class SevenSignsFestival implements SpawnListener
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(GET_CLAN_NAME))
{
ps.setString(1, partyMemberName);

View File

@@ -206,7 +206,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
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

@@ -69,7 +69,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))
{
@@ -86,7 +86,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))
{
@@ -105,7 +105,7 @@ public class CharSummonTable
public void removeServitor(L2PcInstance activeChar)
{
_servitors.remove(activeChar.getObjectId());
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
{
ps.setInt(1, activeChar.getObjectId());
@@ -175,7 +175,7 @@ public class CharSummonTable
public void restoreServitor(L2PcInstance activeChar)
{
final int skillId = _servitors.get(activeChar.getObjectId());
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
{
ps.setInt(1, activeChar.getObjectId());
@@ -222,7 +222,7 @@ public class CharSummonTable
_servitors.put(summon.getOwner().getObjectId(), summon.getReferenceSkill());
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

@@ -81,7 +81,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"))
{
@@ -263,7 +263,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=?"))
{
@@ -376,7 +376,7 @@ public class ClanTable
clan2.setAttackerClan(clan1);
clan1.broadcastClanStatus();
clan2.broadcastClanStatus();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, wantspeace1, wantspeace2) VALUES(?,?,?,?)"))
{
ps.setInt(1, clanId1);
@@ -416,7 +416,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);
@@ -458,7 +458,7 @@ public class ClanTable
private void restorewars()
{
L2Clan clan1, clan2;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery("SELECT clan1, clan2 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

@@ -42,7 +42,7 @@ public class TeleportLocationTable
public void reloadAll()
{
_teleports.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM teleport"))
{
@@ -74,7 +74,7 @@ public class TeleportLocationTable
}
int _cTeleCount = _teleports.size();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id, loc_x, loc_y, loc_z, price, fornoble, itemId FROM custom_teleport"))
{

View File

@@ -67,7 +67,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

@@ -383,7 +383,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

@@ -133,7 +133,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");
@@ -150,7 +150,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();
@@ -261,7 +261,7 @@ public abstract class IdFactory
private void cleanInvalidWeddings()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("DELETE FROM mods_wedding WHERE player1Id NOT IN (SELECT charId FROM characters)");
@@ -276,7 +276,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)
@@ -302,7 +302,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

@@ -163,7 +163,7 @@ public class AirShipManager
final StatsSet info = new StatsSet();
info.set("fuel", 600);
_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);
@@ -233,7 +233,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))
{
@@ -264,7 +264,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

@@ -52,7 +52,7 @@ public final class CHSiegeManager
private final void loadClanHalls()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(SQL_LOAD_HALLS))
{

View File

@@ -282,7 +282,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());
@@ -299,7 +299,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

@@ -158,7 +158,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
private final 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=?"))
{
@@ -432,7 +432,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))
{
@@ -468,7 +468,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))
{
@@ -502,7 +502,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)
@@ -522,7 +522,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)
@@ -595,7 +595,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");
@@ -693,7 +693,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

@@ -98,7 +98,7 @@ public final class ClanHallAuctionManager
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT id FROM auction ORDER BY id"))
{
@@ -163,7 +163,7 @@ public final class ClanHallAuctionManager
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate("INSERT INTO `auction` VALUES " + ITEM_INIT_DATA[i]);

View File

@@ -61,7 +61,7 @@ public final class ClanHallManager
/** Load All Clan Hall */
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM clanhall ORDER BY id"))
{

View File

@@ -51,7 +51,7 @@ public final class CoupleManager
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement ps = con.createStatement();
ResultSet rs = ps.executeQuery("SELECT id FROM mods_wedding ORDER BY id"))
{

View File

@@ -169,7 +169,7 @@ public final class CursedWeaponsManager
private final void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT itemId, charId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons"))
{
@@ -202,7 +202,7 @@ public final class CursedWeaponsManager
// or a lost-child entry in the cursed weapons table, without a corresponding one in items...
// Retrieve the L2PcInstance from the characters table of the database
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
{
for (CursedWeapon cw : _cursedWeapons.values())
@@ -362,7 +362,7 @@ public final class CursedWeaponsManager
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

@@ -74,7 +74,7 @@ public final class DimensionalRiftManager
private void loadRooms()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM dimensional_rift"))
{

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

@@ -99,7 +99,7 @@ public class FishingChampionshipManager
{
_enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement(SELECT);
final ResultSet rs = statement.executeQuery();
@@ -356,7 +356,7 @@ public class FishingChampionshipManager
{
GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE);
statement.execute();

View File

@@ -160,7 +160,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

@@ -104,7 +104,7 @@ public final class FortSiegeGuardManager
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

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

@@ -404,7 +404,7 @@ public final class FourSepulchersManager
{
_mysteriousBoxSpawns.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY id"))
{
ps.setInt(1, 0);
@@ -457,7 +457,7 @@ public final class FourSepulchersManager
_physicalMonsters.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
{
ps1.setInt(1, 1);
@@ -502,7 +502,7 @@ public final class FourSepulchersManager
_magicalMonsters.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
{
ps1.setInt(1, 2);
@@ -549,7 +549,7 @@ public final class FourSepulchersManager
_archonSpawned.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
{
ps1.setInt(1, 5);
@@ -598,7 +598,7 @@ public final class FourSepulchersManager
_emperorsGraveNpcs.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id"))
{
ps1.setInt(1, 6);

View File

@@ -50,7 +50,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))
{
@@ -81,7 +81,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))
{

View File

@@ -73,7 +73,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"))
{
@@ -123,7 +123,7 @@ public final class GrandBossManager implements IStorable
zones.put(zoneId, new ArrayList<>());
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * from grandboss_list ORDER BY player_id"))
{
@@ -229,7 +229,7 @@ public final class GrandBossManager implements IStorable
@Override
public boolean storeMe()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate(DELETE_GRAND_BOSS_LIST);
@@ -302,7 +302,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

@@ -119,7 +119,7 @@ public final class InstanceManager implements IGameXmlReader
restoreInstanceTimes(playerObjId);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(ADD_INSTANCE_TIME))
{
ps.setInt(1, playerObjId);
@@ -141,7 +141,7 @@ public final class InstanceManager implements IGameXmlReader
*/
public void deleteInstanceTime(int playerObjId, int id)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
{
ps.setInt(1, playerObjId);
@@ -165,7 +165,7 @@ public final class InstanceManager implements IGameXmlReader
return; // already restored
}
_playerInstanceTimes.put(playerObjId, new ConcurrentHashMap<>());
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_INSTANCE_TIMES))
{
ps.setInt(1, playerObjId);

View File

@@ -58,7 +58,7 @@ public final class ItemAuctionManager
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1"))
{
@@ -135,7 +135,7 @@ public final class ItemAuctionManager
public static void deleteAuction(int auctionId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = 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;
@@ -173,7 +173,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");
@@ -199,7 +199,7 @@ public final class ItemsOnGroundManager implements Runnable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)"))
{
for (L2ItemInstance item : _items)

View File

@@ -55,7 +55,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"))
{
@@ -165,7 +165,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();
@@ -186,7 +186,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);
@@ -200,7 +200,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);
@@ -214,7 +214,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);
@@ -228,7 +228,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);
@@ -242,7 +242,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

@@ -145,7 +145,7 @@ public final class MercTicketManager
*/
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1"))
{

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

@@ -51,7 +51,7 @@ public class RaidBossPointsManager
private final void init()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT `charId`,`boss_id`,`points` FROM `character_raid_points`"))
{
@@ -78,7 +78,7 @@ public class RaidBossPointsManager
public final void updatePointsInDB(L2PcInstance player, int raidId, int points)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_raid_points (`charId`,`boss_id`,`points`) VALUES (?,?,?)"))
{
ps.setInt(1, player.getObjectId());
@@ -122,7 +122,7 @@ public class RaidBossPointsManager
public final void cleanUp()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("DELETE from character_raid_points WHERE charId > 0"))
{
statement.executeUpdate();

View File

@@ -75,7 +75,7 @@ public class RaidBossSpawnManager
_storedInfo.clear();
_schedules.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM raidboss_spawnlist ORDER BY boss_id"))
{
@@ -247,7 +247,7 @@ public class RaidBossSpawnManager
if (storeInDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, spawnDat.getId());
@@ -307,7 +307,7 @@ public class RaidBossSpawnManager
if (updateDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?"))
{
ps.setInt(1, bossId);
@@ -326,7 +326,7 @@ public class RaidBossSpawnManager
*/
private void updateDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?"))
{
for (Integer bossId : _storedInfo.keySet())

View File

@@ -104,7 +104,7 @@ public final class SiegeGuardManager
*/
public void removeMerc(int npcId, int x, int y, int z)
{
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);
@@ -124,7 +124,7 @@ public final class SiegeGuardManager
*/
public void removeMercs()
{
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());
@@ -191,7 +191,7 @@ public final class SiegeGuardManager
*/
private void loadSiegeGuard()
{
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());
@@ -228,7 +228,7 @@ public final class SiegeGuardManager
*/
private void saveSiegeGuard(int x, int y, int z, int heading, int npcId, int isHire)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)"))
{
ps.setInt(1, _castle.getResidenceId());

View File

@@ -87,7 +87,7 @@ public final class SiegeManager
}
boolean register = false;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?"))
{
ps.setInt(1, clan.getId());
@@ -276,7 +276,7 @@ public final class SiegeManager
private final void loadTrapUpgrade(int castleId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_trapupgrade WHERE castleId=?"))
{
ps.setInt(1, castleId);

View File

@@ -749,7 +749,7 @@ public final class TerritoryWarManager implements Siegable
private void changeRegistration(int castleId, int objId, boolean delete)
{
final String query = delete ? DELETE : INSERT;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
ps.setInt(1, castleId);
@@ -770,7 +770,7 @@ public final class TerritoryWarManager implements Siegable
wardList.append(i + ";");
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE territories SET ownedWardIds=? WHERE territoryId=?"))
{
ps.setString(1, wardList.toString());
@@ -800,7 +800,7 @@ public final class TerritoryWarManager implements Siegable
MINTWBADGEFORSTRIDERS = territoryWarSettings.getInt("MinTerritoryBadgeForStriders", 50);
MINTWBADGEFORBIGSTRIDER = territoryWarSettings.getInt("MinTerritoryBadgeForBigStrider", 80);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM territory_spawnlist"))
{
@@ -840,7 +840,7 @@ public final class TerritoryWarManager implements Siegable
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": SpawnList error: " + e.getMessage(), e);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM territories"))
{
@@ -878,7 +878,7 @@ public final class TerritoryWarManager implements Siegable
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": territory list error(): " + e.getMessage(), e);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM territory_registrations"))
{

View File

@@ -91,7 +91,7 @@ public class Lottery
public void increasePrize(long count)
{
_prize += count;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_PRICE))
{
ps.setLong(1, _prize);
@@ -125,7 +125,7 @@ public class Lottery
@Override
public void run()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery(SELECT_LAST_LOTTERY))
{
@@ -194,7 +194,7 @@ public class Lottery
ThreadPool.schedule(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
ThreadPool.schedule(new finishLottery(), _enddate - System.currentTimeMillis());
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_LOTTERY))
{
ps.setInt(1, 1);
@@ -281,7 +281,7 @@ public class Lottery
int count3 = 0;
int count4 = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_ITEM))
{
ps.setInt(1, _number);
@@ -382,7 +382,7 @@ public class Lottery
}
Broadcast.toAllOnlinePlayers(sm);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_LOTTERY))
{
ps.setLong(1, _prize);
@@ -452,7 +452,7 @@ public class Lottery
0,
0
};
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_LOTTERY_TICKET))
{
ps.setInt(1, id);

View File

@@ -123,7 +123,7 @@ public class AutoSpawnHandler
private void restoreSpawnData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))

View File

@@ -70,7 +70,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);
@@ -97,7 +97,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

@@ -138,7 +138,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 karma=?, pkkills=? WHERE charId=?"))
{
@@ -475,7 +475,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, playerKarma, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
{

View File

@@ -249,7 +249,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);
@@ -289,7 +289,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));
@@ -871,7 +871,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);
@@ -915,7 +915,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);
@@ -933,7 +933,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void updateInDB()
{
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);
@@ -962,7 +962,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());
@@ -1000,7 +1000,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);
@@ -1032,7 +1032,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
private void removeMemberInDatabase(int playerId, 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=?"))
@@ -1058,7 +1058,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);
@@ -1133,7 +1133,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);
@@ -1164,7 +1164,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);
@@ -1219,7 +1219,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
@@ -1326,7 +1326,7 @@ public class L2Clan implements IIdentifiable, INamable
oldSkill = subunit.addNewSkill(newSkill);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (oldSkill != null)
{
@@ -1769,7 +1769,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
@@ -1869,7 +1869,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);
@@ -1952,7 +1952,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());
@@ -1969,7 +1969,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
@@ -2018,7 +2018,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);
@@ -2727,7 +2727,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);
@@ -2773,7 +2773,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);
@@ -2810,7 +2810,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);
@@ -2856,7 +2856,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

@@ -232,7 +232,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);
@@ -277,7 +277,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);
@@ -788,7 +788,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

@@ -128,7 +128,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());
@@ -164,7 +164,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());
@@ -181,7 +181,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,class_index) values(?,?,?,?,?,?,?)"))
{
statement.setInt(1, _owner.getObjectId());
@@ -153,7 +153,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());
@@ -172,7 +172,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 FROM character_shortcuts WHERE charId=? AND class_index=?"))
{
statement.setInt(1, _owner.getObjectId());

View File

@@ -104,7 +104,7 @@ public class UIKeysSettings
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
@@ -125,7 +125,7 @@ public class UIKeysSettings
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
@@ -146,7 +146,7 @@ public class UIKeysSettings
_storedCategories = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
ps.setInt(1, _playerObjId);
@@ -178,7 +178,7 @@ public class UIKeysSettings
_storedKeys = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
ps.setInt(1, _playerObjId);

View File

@@ -1357,7 +1357,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 ps = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)"))
{
ps.setInt(1, getObjectId());
@@ -1374,7 +1374,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 ps = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?"))
{
ps.setInt(1, getObjectId());
@@ -6673,7 +6673,7 @@ public final class L2PcInstance extends L2Playable
*/
public void updateOnlineStatus()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?"))
{
ps.setInt(1, isOnlineInt());
@@ -6693,7 +6693,7 @@ public final class L2PcInstance extends L2Playable
*/
private boolean createDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CHARACTER))
{
ps.setString(1, _accountName);
@@ -6758,7 +6758,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 ps = con.prepareStatement(RESTORE_CHARACTER))
{
// Retrieve the L2PcInstance from the characters table of the database
@@ -7087,7 +7087,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 ps = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
{
ps.setInt(1, player.getObjectId());
@@ -7168,7 +7168,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 ps = con.prepareStatement(sql))
{
ps.setInt(1, getObjectId());
@@ -7221,7 +7221,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 ps = con.prepareStatement(sql))
{
ps.setInt(1, getObjectId());
@@ -7241,7 +7241,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 ps = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? "))
{
ps.setLong(1, newcount);
@@ -7257,7 +7257,7 @@ public final class L2PcInstance extends L2Playable
public void deletePremiumItem(int itemNum)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? "))
{
ps.setInt(1, getObjectId());
@@ -7315,7 +7315,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 ps = con.prepareStatement(UPDATE_CHARACTER))
{
ps.setInt(1, level);
@@ -7403,7 +7403,7 @@ public final class L2PcInstance extends L2Playable
}
// TODO(Zoey76): Refactor this to use batch.
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
{
for (SubClass subClass : getSubClasses().values())
@@ -7432,7 +7432,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);)
{
@@ -7537,7 +7537,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))
{
@@ -7658,7 +7658,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 ps = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
{
// Remove or update a L2PcInstance skill from the character_skills table of the database
@@ -7701,7 +7701,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))
{
@@ -7749,7 +7749,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);
@@ -7775,7 +7775,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreSkills()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -7823,7 +7823,7 @@ public final class L2PcInstance extends L2Playable
@Override
public void restoreEffects()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
{
ps.setInt(1, getObjectId());
@@ -7880,7 +7880,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreItemReuse()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);)
{
@@ -7951,7 +7951,7 @@ public final class L2PcInstance extends L2Playable
_henna[i] = null;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_HENNAS))
{
ps.setInt(1, getObjectId());
@@ -8039,7 +8039,7 @@ public final class L2PcInstance extends L2Playable
_henna[slot] = null;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_CHAR_HENNA))
{
ps.setInt(1, getObjectId());
@@ -8092,7 +8092,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 ps = con.prepareStatement(ADD_CHAR_HENNA))
{
ps.setInt(1, getObjectId());
@@ -10121,7 +10121,7 @@ public final class L2PcInstance extends L2Playable
newClass.setClassId(classId);
newClass.setClassIndex(classIndex);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(ADD_CHAR_SUBCLASS))
{
// Store the basic info about this new sub-class.
@@ -10186,7 +10186,7 @@ public final class L2PcInstance extends L2Playable
try
{
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);
@@ -12770,7 +12770,7 @@ public final class L2PcInstance extends L2Playable
return;
}
final String req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(req))
{
ps.setInt(1, _curFeed);
@@ -12919,7 +12919,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 ps = con.prepareStatement(UPDATE_TP_BOOKMARK))
{
ps.setInt(1, icon);
@@ -12944,7 +12944,7 @@ public final class L2PcInstance extends L2Playable
{
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_TP_BOOKMARK))
{
ps.setInt(1, getObjectId());
@@ -13090,7 +13090,7 @@ public final class L2PcInstance extends L2Playable
sm.addItemName(20033);
sendPacket(sm);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_TP_BOOKMARK))
{
ps.setInt(1, getObjectId());
@@ -13112,7 +13112,7 @@ public final class L2PcInstance extends L2Playable
public void restoreTeleportBookmark()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_TP_BOOKMARK))
{
ps.setInt(1, getObjectId());
@@ -13350,7 +13350,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 ps = con.prepareStatement(sqlQuery))
{
ps.setInt(1, getObjectId());
@@ -13440,7 +13440,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))
{
@@ -13478,7 +13478,7 @@ public final class L2PcInstance extends L2Playable
_manufactureItems.clear();
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
{
ps.setInt(1, getObjectId());
@@ -13922,7 +13922,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restorePetInventoryItems()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
{
ps.setInt(1, getObjectId());
@@ -13964,7 +13964,7 @@ public final class L2PcInstance extends L2Playable
private long loadRecommendations()
{
long _time_left = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1"))
{
ps.setInt(1, getObjectId());
@@ -14007,7 +14007,7 @@ public final class L2PcInstance extends L2Playable
}
}
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

@@ -775,7 +775,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 ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
{
ps.setInt(1, _controlObjectId);
@@ -834,7 +834,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 ps = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
{
L2PetInstance pet;
@@ -926,7 +926,7 @@ public class L2PetInstance extends L2Summon
}
final String req = !_respawned ? "INSERT INTO pets (name,level,curHp,curMp,exp,sp,fed,ownerId,restore,item_obj_id) VALUES (?,?,?,?,?,?,?,?,?,?)" : "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 ps = con.prepareStatement(req))
{
ps.setString(1, getName());
@@ -976,7 +976,7 @@ public class L2PetInstance extends L2Summon
// Clear list for overwrite
SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
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))
{
@@ -1044,7 +1044,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

@@ -217,7 +217,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
// Clear list for overwrite
SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE))
{
// Delete all current stored effects for summon to avoid dupe
@@ -296,7 +296,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), 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 ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{
ps.setInt(1, getType().ordinal());
@@ -123,7 +123,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override
public boolean updateMe()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{
ps.setInt(1, getType().ordinal());

View File

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

View File

@@ -162,7 +162,7 @@ public class Auction
/** Load auctions */
private void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?"))
{
ps.setInt(1, _id);
@@ -197,7 +197,7 @@ public class Auction
_highestBidderName = "";
_highestBidderMaxBid = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
{
ps.setInt(1, _id);
@@ -246,7 +246,7 @@ public class Auction
/** Save Auction Data End */
private void saveAuctionDate()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("Update auction set endDate = ? where id = ?"))
{
ps.setLong(1, _endDate);
@@ -337,7 +337,7 @@ public class Auction
*/
private void updateInDB(L2PcInstance bidder, long bid)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (_bidders.get(bidder.getClanId()) != null)
{
@@ -394,7 +394,7 @@ public class Auction
/** Remove bids */
private void removeBids()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
{
ps.setInt(1, _id);
@@ -424,7 +424,7 @@ public class Auction
public void deleteAuctionFromDB()
{
ClanHallAuctionManager.getInstance().getAuctions().remove(this);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
{
ps.setInt(1, _itemId);
@@ -480,7 +480,7 @@ public class Auction
*/
public synchronized void cancelBid(int bidder)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
{
ps.setInt(1, _id);
@@ -509,7 +509,7 @@ public class Auction
public void confirmAuction()
{
ClanHallAuctionManager.getInstance().getAuctions().add(this);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, _id);

View File

@@ -212,7 +212,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());
@@ -345,7 +345,7 @@ public final class Castle extends AbstractResidence
}
}
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);
@@ -578,7 +578,7 @@ public final class Castle extends AbstractResidence
_taxPercent = taxPercent;
_taxRate = _taxPercent / 100.0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET taxPercent = ? WHERE id = ?"))
{
ps.setInt(1, taxPercent);
@@ -625,7 +625,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 = ?"))
{
@@ -671,7 +671,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());
@@ -696,7 +696,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());
@@ -768,7 +768,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());
@@ -794,7 +794,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());
@@ -819,7 +819,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);
@@ -846,7 +846,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 = ?"))
@@ -1001,7 +1001,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));
@@ -1096,7 +1096,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);
@@ -1119,7 +1119,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());
@@ -1146,7 +1146,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());

View File

@@ -180,7 +180,7 @@ public abstract class ClanHall
public void dbSave()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO clanhall_functions (hall_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
{
ps.setInt(1, _clanHallId);
@@ -440,7 +440,7 @@ public abstract class ClanHall
/** Load All Functions */
protected void loadFunctions()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM clanhall_functions WHERE hall_id = ?"))
{
ps.setInt(1, _clanHallId);
@@ -465,7 +465,7 @@ public abstract class ClanHall
public void removeFunction(int functionType)
{
_functions.remove(functionType);
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_functions WHERE hall_id=? AND type=?"))
{
ps.setInt(1, _clanHallId);

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());
@@ -484,7 +484,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);
@@ -549,7 +549,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());
@@ -610,7 +610,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());
@@ -635,7 +635,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());
@@ -727,7 +727,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());
@@ -747,7 +747,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());
@@ -761,7 +761,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);
@@ -790,7 +790,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);
@@ -987,7 +987,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);
@@ -1119,7 +1119,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());
@@ -1148,7 +1148,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());
@@ -1175,7 +1175,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());
@@ -1205,7 +1205,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

@@ -491,7 +491,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());
@@ -775,7 +775,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 ps = con.prepareStatement(query))
{
ps.setInt(1, _fort.getResidenceId());
@@ -989,7 +989,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());
@@ -1051,7 +1051,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, getFort().getSiegeDate().getTimeInMillis());
@@ -1075,7 +1075,7 @@ public class FortSiege implements Siegable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
{
ps.setInt(1, clan.getId());

View File

@@ -108,7 +108,7 @@ public class Hero
HERO_DIARY.clear();
HERO_MESSAGE.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);
@@ -203,7 +203,7 @@ public class Hero
*/
public void loadMessage(int charId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
{
ps.setInt(1, charId);
@@ -225,7 +225,7 @@ public class Hero
{
final List<StatsSet> diary = new ArrayList<>();
int diaryentries = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
{
ps.setInt(1, charId);
@@ -292,7 +292,7 @@ public class Hero
int _losses = 0;
int _draws = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
{
ps.setInt(1, charId);
@@ -689,7 +689,7 @@ public class Hero
public void updateHeroes(boolean setDefault)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (setDefault)
{
@@ -822,7 +822,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 ps = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
{
ps.setInt(1, charId);
@@ -858,7 +858,7 @@ public class Hero
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{
ps.setString(1, HERO_MESSAGE.get(charId));
@@ -873,7 +873,7 @@ public class Hero
private void deleteItemsInDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate(DELETE_ITEMS);

View File

@@ -724,7 +724,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 ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
{
ps.setInt(1, getCastle().getResidenceId());
@@ -752,7 +752,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 ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
{
ps.setInt(1, getCastle().getResidenceId());
@@ -972,7 +972,7 @@ public class Siege implements Siegable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
{
ps.setInt(1, getCastle().getResidenceId());
@@ -1237,7 +1237,7 @@ public class Siege implements Siegable
/** Load siege clans. */
private void loadSiegeClan()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
{
getAttackerClans().clear();
@@ -1348,7 +1348,7 @@ public class Siege implements Siegable
_scheduledStartSiegeTask = ThreadPool.schedule(new ScheduleStartSiegeTask(getCastle()), 1000);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
{
ps.setLong(1, getSiegeDate().getTimeInMillis());
@@ -1377,7 +1377,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

@@ -215,7 +215,7 @@ public final class AuctionableHall extends ClanHall
@Override
public final void updateDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
{
ps.setInt(1, getOwnerId());

View File

@@ -93,7 +93,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
public void loadAttackers()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{
ps.setInt(1, _hall.getId());
@@ -114,7 +114,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
public final void saveAttackers()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
{
ps.setInt(1, _hall.getId());
@@ -148,7 +148,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
return;
}
_guards = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_GUARDS))
{
ps.setInt(1, _hall.getId());

View File

@@ -130,7 +130,7 @@ public final class SiegableHall extends ClanHall
@Override
public final void updateDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE))
{
ps.setInt(1, getOwnerId());

View File

@@ -192,7 +192,7 @@ public final class ItemAuction
public final void storeMe()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
{
ps.setInt(1, _auctionId);
@@ -226,7 +226,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

@@ -162,7 +162,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);
@@ -527,7 +527,7 @@ public final class ItemAuctionInstance
private final 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

@@ -1793,7 +1793,7 @@ public abstract class Inventory extends ItemContainer
@Override
public void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
{
statement.setInt(1, getOwnerId());

View File

@@ -620,7 +620,7 @@ public abstract class ItemContainer
*/
public void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=?)"))
{
ps.setInt(1, getOwnerId());

View File

@@ -116,7 +116,7 @@ public class Mail extends ItemContainer
@Override
public void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
{
ps.setInt(1, _ownerId);

View File

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

View File

@@ -898,7 +898,7 @@ public final class L2ItemInstance extends L2Object
}
_augmentation = augmentation;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
updateItemAttributes(con);
}
@@ -924,7 +924,7 @@ public final class L2ItemInstance extends L2Object
final L2Augmentation augment = _augmentation;
_augmentation = null;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?"))
{
ps.setInt(1, getObjectId());
@@ -941,7 +941,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 augAttributes FROM item_attributes WHERE itemId=?");
PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
{
@@ -1139,7 +1139,7 @@ public final class L2ItemInstance extends L2Object
public void setElementAttr(byte element, int value)
{
applyAttribute(element, value);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
updateItemElements(con);
}
@@ -1176,7 +1176,7 @@ public final class L2ItemInstance extends L2Object
_elementals = array;
final String query = (element != -1) ? "DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?" : "DELETE FROM item_elementals WHERE itemId = ?";
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
if (element != -1)
@@ -1598,7 +1598,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);
@@ -1631,7 +1631,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);
@@ -1675,7 +1675,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 = ?"))
{

View File

@@ -175,7 +175,7 @@ public class Olympiad extends ListenersContainer
{
NOBLES.clear();
boolean loaded = false;
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rset = s.executeQuery(OLYMPIAD_LOAD_DATA))
{
@@ -253,7 +253,7 @@ public class Olympiad extends ListenersContainer
}
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rset = s.executeQuery(OLYMPIAD_LOAD_NOBLES))
{
@@ -321,7 +321,7 @@ public class Olympiad extends ListenersContainer
{
NOBLES_RANK.clear();
final Map<Integer, Integer> tmpPlace = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery(GET_ALL_CLASSIFIED_NOBLESS))
{
@@ -839,7 +839,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())
{
@@ -911,7 +911,7 @@ public class Olympiad extends ListenersContainer
{
saveNobleData();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(OLYMPIAD_SAVE_DATA))
{
ps.setInt(1, _currentCycle);
@@ -952,7 +952,7 @@ public class Olympiad extends ListenersContainer
protected void updateMonthlyData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s1 = con.createStatement();
Statement s2 = con.createStatement())
{
@@ -994,7 +994,7 @@ public class Olympiad extends ListenersContainer
}
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(OLYMPIAD_GET_HEROS))
{
StatsSet hero;
@@ -1101,7 +1101,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);
@@ -1184,7 +1184,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);
@@ -1300,7 +1300,7 @@ public class Olympiad extends ListenersContainer
protected void deleteNobles()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement())
{
s.executeUpdate(OLYMPIAD_DELETE_ALL);

View File

@@ -713,7 +713,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 ps = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, one.getObjectId());

View File

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

View File

@@ -383,7 +383,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

@@ -1468,7 +1468,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 = ?"))
@@ -1556,7 +1556,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());
@@ -1580,7 +1580,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);
@@ -1602,7 +1602,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());
@@ -1623,7 +1623,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

@@ -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))

View File

@@ -52,7 +52,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);
@@ -85,7 +85,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))

View File

@@ -286,7 +286,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
return -1;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("SELECT clanId FROM characters WHERE charId=?"))
{
statement.setInt(1, objectId);
@@ -349,7 +349,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);
@@ -372,7 +372,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

@@ -65,7 +65,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

@@ -122,7 +122,7 @@ public class RequestBrBuyProduct implements IClientIncomingPacket
player.broadcastUserInfo();
// Save transaction info at SQL table item_mall_transactions
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO item_mall_transactions (charId, productId, quantity) values (?,?,?)"))
{
statement.setLong(1, player.getObjectId());

View File

@@ -152,7 +152,7 @@ public final class RequestDestroyItem implements IClientIncomingPacket
activeChar.getSummon().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

@@ -74,7 +74,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

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

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