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,117 +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
* @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.
// 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

@@ -184,7 +184,7 @@ public class GameServer
Config.load();
Util.printSection("Database");
DatabaseFactory.getInstance();
DatabaseFactory.init();
Util.printSection("ThreadPool");
ThreadPool.init();

View File

@@ -357,7 +357,7 @@ public class Shutdown extends Thread
// commit data, last chance
try
{
DatabaseFactory.getInstance().close();
DatabaseFactory.close();
}
catch (Throwable t)
{

View File

@@ -175,7 +175,7 @@ public class TradeController
int dummyItemCount = 0;
boolean LimitedItem = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement1 = con.prepareStatement("SELECT * FROM merchant_shopids");
@@ -355,7 +355,7 @@ public class TradeController
*/
if (Config.CUSTOM_MERCHANT_TABLES)// Custom merchat Tabels
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final int initialSize = _lists.size();
@@ -614,7 +614,7 @@ public class TradeController
protected void dataTimerSave(int time)
{
final long timerSave = System.currentTimeMillis() + (time * 60 * 60 * 1000);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE merchant_buylists SET savetimer =? WHERE time =?");
statement.setLong(1, timerSave);
@@ -638,7 +638,7 @@ public class TradeController
}
PreparedStatement statement;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
for (L2TradeList list : _listsTaskItem.values())
{

View File

@@ -167,7 +167,7 @@ public class CrestCache
file.renameTo(new File(Config.DATAPACK_ROOT, "data/crests/Crest_" + newId + ".bmp"));
LOGGER.info("Renamed Clan crest to new format: Crest_" + newId + ".bmp");
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?");
statement.setInt(1, newId);

View File

@@ -95,7 +95,7 @@ public class Forum
private void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?");
statement.setInt(1, _forumId);
@@ -119,7 +119,7 @@ public class Forum
LOGGER.warning("Data error on Forum " + _forumId + " : " + e);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM topic WHERE topic_forum_id=? ORDER BY topic_id DESC");
statement.setInt(1, _forumId);
@@ -146,7 +146,7 @@ public class Forum
private void getChildren()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_parent=?");
statement.setInt(1, _forumId);
@@ -226,7 +226,7 @@ public class Forum
public void insertIntoDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO forums (forum_id,forum_name,forum_parent,forum_post,forum_type,forum_perm,forum_owner_id) values (?,?,?,?,?,?,?)");
statement.setInt(1, _forumId);

View File

@@ -71,7 +71,7 @@ public class Post
public void insertindb(CPost cp)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)");
statement.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 statement = con.prepareStatement("DELETE FROM posts WHERE post_forum_id=? AND post_topic_id=?");
statement.setInt(1, t.getForumID());
@@ -128,7 +128,7 @@ public class Post
private void load(Topic t)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM posts WHERE post_forum_id=? AND post_topic_id=? ORDER BY post_id ASC");
statement.setInt(1, t.getForumID());
@@ -157,7 +157,7 @@ public class Post
public void updateText(int i)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
CPost cp = getCPost(i);
PreparedStatement statement = con.prepareStatement("UPDATE posts SET post_txt=? WHERE post_id=? AND post_topic_id=? AND post_forum_id=?");

View File

@@ -69,7 +69,7 @@ public class Topic
private void insertIntoDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)");
statement.setInt(1, _id);
@@ -125,7 +125,7 @@ public class Topic
TopicBBSManager.getInstance().delTopic(this);
f.rmTopicByID(_id);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?");
statement.setInt(1, _id);

View File

@@ -56,7 +56,7 @@ public class FavoriteBBSManager extends BaseBBSManager
// Load Favorite links
final String list = HtmCache.getInstance().getHtm(CB_PATH + "favorite_list.html");
final StringBuilder sb = new StringBuilder();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
{
ps.setInt(1, activeChar.getObjectId());
@@ -93,7 +93,7 @@ public class FavoriteBBSManager extends BaseBBSManager
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
{
ps.setInt(1, activeChar.getObjectId());
@@ -118,7 +118,7 @@ public class FavoriteBBSManager extends BaseBBSManager
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
{
ps.setInt(1, activeChar.getObjectId());

View File

@@ -39,7 +39,7 @@ public class ForumsBBSManager extends BaseBBSManager
{
_table = new CopyOnWriteArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_type=0");
ResultSet result = statement.executeQuery();

View File

@@ -79,7 +79,7 @@ public class FriendsBBSManager extends BaseBBSManager
}
else if (action.equals("delall"))
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE char_id = ? OR friend_id = ?");
statement.setInt(1, activeChar.getObjectId());
@@ -117,7 +117,7 @@ public class FriendsBBSManager extends BaseBBSManager
}
else if (action.equals("del"))
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
for (int friendId : activeChar.getSelectedFriendList())
{

View File

@@ -223,7 +223,7 @@ public class MailBBSManager extends BaseBBSManager
private void initId()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(SELECT_LAST_ID);
ResultSet result = statement.executeQuery();
@@ -255,7 +255,7 @@ public class MailBBSManager extends BaseBBSManager
if (_letters == null)
{
_letters = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(SELECT_CHAR_MAILS);
statement.setInt(1, objId);
@@ -570,7 +570,7 @@ public class MailBBSManager extends BaseBBSManager
// Edit message.
message = message.replaceAll("\n", "<br1>");
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// Get the current time under timestamp format.
final Timestamp time = new Timestamp(currentDate);
@@ -758,7 +758,7 @@ public class MailBBSManager extends BaseBBSManager
}
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE_MAIL);
statement.setInt(1, letterId);
@@ -775,7 +775,7 @@ public class MailBBSManager extends BaseBBSManager
{
getLetter(activeChar, letterId).unread = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(MARK_MAIL_READ);
statement.setInt(1, 0);
@@ -793,7 +793,7 @@ public class MailBBSManager extends BaseBBSManager
{
getLetter(activeChar, letterId).location = location;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(SET_LETTER_LOC);
statement.setString(1, location.toString().toLowerCase());
@@ -816,7 +816,7 @@ public class MailBBSManager extends BaseBBSManager
private static boolean isGM(int charId)
{
boolean isGM = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT accesslevel FROM characters WHERE obj_Id = ?");
statement.setInt(1, charId);

View File

@@ -59,7 +59,7 @@ public class BufferTable
{
int count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement st = con.prepareStatement(LOAD_SCHEMES);
ResultSet rs = st.executeQuery();
@@ -136,7 +136,7 @@ public class BufferTable
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

@@ -56,7 +56,7 @@ public class OfflineTradeTable
// of store of normal sellers/buyers also if not in offline mode
public static void storeOffliners()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stm = con.prepareStatement(CLEAR_OFFLINE_TABLE);
stm.execute();
@@ -174,7 +174,7 @@ public class OfflineTradeTable
{
LOGGER.info("Loading offline traders...");
int nTraders = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement stm = con.prepareStatement(LOAD_OFFLINE_STATUS);
final ResultSet rs = stm.executeQuery();
@@ -305,7 +305,7 @@ public class OfflineTradeTable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stm = con.prepareStatement(DELETE_OFFLINE_TABLE_ALL_ITEMS);
stm.setInt(1, pc.getObjectId());

View File

@@ -69,7 +69,7 @@ public class AccessLevels
_masterAccessLevel = new AccessLevel(Config.MASTERACCESS_LEVEL, "Master Access", Config.MASTERACCESS_NAME_COLOR, Config.MASTERACCESS_TITLE_COLOR, true, true, true, true, true, true, true, true, true, true, true);
_userAccessLevel = new AccessLevel(Config.USERACCESS_LEVEL, "User", Integer.decode("0xFFFFFF"), Integer.decode("0xFFFFFF"), false, false, false, true, false, true, true, true, true, true, false);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement stmt = con.prepareStatement("SELECT * FROM `access_levels` ORDER BY `accessLevel` DESC");
final ResultSet rset = stmt.executeQuery();

View File

@@ -53,7 +53,7 @@ public class AdminCommandAccessRights
*/
private AdminCommandAccessRights()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement stmt = con.prepareStatement("SELECT * FROM admin_command_access_rights");
final ResultSet rset = stmt.executeQuery();

View File

@@ -53,7 +53,7 @@ public class ArmorSetsTable
private void loadData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT id, chest, legs, head, gloves, feet, skill_id, shield, shield_skill_id, enchant6skill FROM armorsets");
final ResultSet rset = statement.executeQuery();

View File

@@ -42,7 +42,7 @@ public class CharNameTable
public synchronized boolean doesCharNameExist(String name)
{
boolean result = true;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT account_name FROM characters WHERE char_name=?");
statement.setString(1, name);
@@ -63,7 +63,7 @@ public class CharNameTable
{
String name = "";
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT char_name FROM characters WHERE obj_Id=?");
statement.setInt(1, objId);
@@ -90,7 +90,7 @@ public class CharNameTable
{
int id = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT obj_Id FROM characters WHERE char_name=?");
statement.setString(1, name);
@@ -117,7 +117,7 @@ public class CharNameTable
{
int accessLevel = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT accesslevel FROM characters WHERE obj_Id=?");
statement.setInt(1, objId);
@@ -144,7 +144,7 @@ public class CharNameTable
{
int number = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT COUNT(char_name) FROM characters WHERE account_name=?");
statement.setString(1, account);

View File

@@ -176,7 +176,7 @@ public class CharTemplateTable
private CharTemplateTable()
{
_templates = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list, char_templates, lvlupgain WHERE class_list.id = char_templates.classId AND class_list.id = lvlupgain.classId ORDER BY class_list.id");
ResultSet rset = statement.executeQuery();

View File

@@ -112,7 +112,7 @@ public class ClanTable
{
_clans = new HashMap<>();
L2Clan clan;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT * FROM clan_data");
final ResultSet result = statement.executeQuery();
@@ -355,7 +355,7 @@ public class ClanTable
_clans.remove(clanId);
IdFactory.getInstance().releaseId(clanId);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM clan_data WHERE clan_id=?");
statement.setInt(1, clanId);
@@ -462,7 +462,7 @@ public class ClanTable
clan1.broadcastClanStatus();
clan2.broadcastClanStatus();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, wantspeace1, wantspeace2) VALUES(?,?,?,?)");
statement.setInt(1, clanId1);
@@ -514,7 +514,7 @@ public class ClanTable
// player.getPlayerInstance().setWantsPeace(0);
// }
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? AND clan2=?");
statement.setInt(1, clanId1);
@@ -570,7 +570,7 @@ public class ClanTable
private void restorewars()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT clan1, clan2, wantspeace1, wantspeace2 FROM clan_wars");
final ResultSet rset = statement.executeQuery();

View File

@@ -43,7 +43,7 @@ public final class CustomArmorSetsTable
public CustomArmorSetsTable()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT chest, legs, head, gloves, feet, skill_id, shield, shield_skill_id, enchant6skill FROM custom_armorsets");
final ResultSet rset = statement.executeQuery();

View File

@@ -86,7 +86,7 @@ public class HelperBuffTable
*/
private void restoreHelperBuffData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT * FROM helper_buff_list");
final ResultSet helperbuffdata = statement.executeQuery();

View File

@@ -55,7 +55,7 @@ public class HennaTreeTable
int classId = 0;
int count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT class_name, id, parent_id FROM class_list ORDER BY id");
final ResultSet classlist = statement.executeQuery();

View File

@@ -52,7 +52,7 @@ public class L2PetDataTable
public void loadPetsData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT typeID, level, expMax, hpMax, mpMax, patk, pdef, matk, mdef, acc, evasion, crit, speed, atk_speed, cast_speed, feedMax, feedbattle, feednormal, loadMax, hpregen, mpregen, owner_exp_taken FROM pets_stats");
final ResultSet rset = statement.executeQuery();

View File

@@ -66,7 +66,7 @@ public class LevelUpData
private LevelUpData()
{
lvlTable = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement(SELECT_ALL);
final ResultSet rset = statement.executeQuery();

View File

@@ -71,7 +71,7 @@ public class NpcTable
private void restoreNpcData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM npc");
final ResultSet npcdata = statement.executeQuery();
@@ -86,7 +86,7 @@ public class NpcTable
if (Config.CUSTOM_NPC_TABLE)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM custom_npc");
final ResultSet npcdata = statement.executeQuery();
@@ -100,7 +100,7 @@ public class NpcTable
}
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
final ResultSet npcskills = statement.executeQuery();
@@ -146,7 +146,7 @@ public class NpcTable
if (Config.CUSTOM_DROPLIST_TABLE)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM custom_droplist ORDER BY mobId, chance DESC");
final ResultSet dropData = statement.executeQuery();
@@ -186,7 +186,7 @@ public class NpcTable
}
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM droplist ORDER BY mobId, chance DESC");
final ResultSet dropData = statement.executeQuery();
@@ -225,7 +225,7 @@ public class NpcTable
LOGGER.warning("NPCTable: Error reading NPC drop data." + e);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM skill_learn");
final ResultSet learndata = statement.executeQuery();
@@ -259,7 +259,7 @@ public class NpcTable
LOGGER.warning("NPCTable: Error reading NPC trainer data." + e);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM minions");
final ResultSet minionData = statement.executeQuery();
@@ -554,7 +554,7 @@ public class NpcTable
public void reloadNpc(int id)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// save a copy of the old data
final L2NpcTemplate old = getTemplate(id);
@@ -628,7 +628,7 @@ public class NpcTable
public void saveNpc(StatsSet npc)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final Map<String, Object> set = npc.getSet();

View File

@@ -47,7 +47,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())
{
final PreparedStatement statement = con.prepareStatement("SELECT name FROM pets p, items i WHERE p.item_obj_id = i.object_id AND name=? AND i.item_id IN (?)");
statement.setString(1, name);

View File

@@ -49,7 +49,7 @@ public class SkillSpellbookTable
private SkillSpellbookTable()
{
skillSpellbooks = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT skill_id, item_id FROM skill_spellbooks");
final ResultSet spbooks = statement.executeQuery();

View File

@@ -57,7 +57,7 @@ public class SkillTreeTable
int classId = 0;
int count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list ORDER BY id");
final ResultSet classlist = statement.executeQuery();
@@ -122,7 +122,7 @@ public class SkillTreeTable
int count2 = 0;
int count3 = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
_fishingSkillTrees = new ArrayList<>();
_expandDwarfCraftSkillTrees = new ArrayList<>();
@@ -172,7 +172,7 @@ public class SkillTreeTable
}
int count4 = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
_enchantSkillTrees = new ArrayList<>();
@@ -215,7 +215,7 @@ public class SkillTreeTable
}
int count5 = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
_pledgeSkillTrees = new ArrayList<>();

View File

@@ -68,7 +68,7 @@ public class SpawnTable
private void fillSpawnTable()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -173,7 +173,7 @@ public class SpawnTable
// -------------------------------Custom Spawnlist----------------------------//
if (Config.CUSTOM_SPAWNLIST_TABLE)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement;
@@ -284,7 +284,7 @@ public class SpawnTable
if (storeInDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("INSERT INTO " + (spawn.isCustom() ? "custom_spawnlist" : "spawnlist") + "(id,count,npc_templateid,locx,locy,locz,heading,respawn_delay,loc_id) values(?,?,?,?,?,?,?,?,?)");
statement.setInt(1, spawn.getId());
@@ -317,7 +317,7 @@ public class SpawnTable
{
if (Config.DELETE_GMSPAWN_ON_CUSTOM)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("Replace into custom_notspawned VALUES (?,?)");
statement.setInt(1, spawn.getId());
@@ -332,7 +332,7 @@ public class SpawnTable
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("DELETE FROM " + (spawn.isCustom() ? "custom_spawnlist" : "spawnlist") + " WHERE id=?");
statement.setInt(1, spawn.getId());

View File

@@ -58,7 +58,7 @@ public class TeleportLocationTable
{
teleports = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT Description, id, loc_x, loc_y, loc_z, price, fornoble FROM teleport");
final ResultSet rset = statement.executeQuery();
@@ -90,7 +90,7 @@ public class TeleportLocationTable
if (Config.CUSTOM_TELEPORT_TABLE)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT Description, id, loc_x, loc_y, loc_z, price, fornoble FROM custom_teleport");
final ResultSet rset = statement.executeQuery();

View File

@@ -57,7 +57,7 @@ public class TerritoryTable
public void reload_data()
{
_territory.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT loc_id, loc_x, loc_y, loc_zmin, loc_zmax, proc FROM `locations`");
final ResultSet rset = statement.executeQuery();

View File

@@ -80,7 +80,7 @@ public class TradeListTable
private void load(boolean custom)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement1 = con.prepareStatement("SELECT shop_id,npc_id FROM " + (custom ? "custom_merchant_shopids" : "merchant_shopids"));
final ResultSet rset1 = statement1.executeQuery();
@@ -266,7 +266,7 @@ public class TradeListTable
{
final long timerSave = System.currentTimeMillis() + (time * 3600000); // 60*60*1000
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE merchant_buylists SET savetimer =? WHERE time =?");
statement.setLong(1, timerSave);
@@ -288,7 +288,7 @@ public class TradeListTable
}
int listId;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -319,7 +319,7 @@ public class ItemTable
// if it's a pet control item, delete the pet as well
if (L2PetDataTable.isPetItem(item.getItemId()))
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?");
statement.setInt(1, item.getObjectId());

View File

@@ -123,7 +123,7 @@ public class ZoneData
boolean done = false;
// Load the zone xml
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);

View File

@@ -54,7 +54,7 @@ public class AutoAnnouncementHandler
PreparedStatement statement = null;
ResultSet rs = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement("SELECT * FROM auto_announcements ORDER BY id");
rs = statement.executeQuery();
@@ -169,7 +169,7 @@ public class AutoAnnouncementHandler
{
final int nextId = nextAutoAnnouncmentId();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO auto_announcements (id,announcement,delay) VALUES (?,?,?)");
statement.setInt(1, nextId);
@@ -195,7 +195,7 @@ public class AutoAnnouncementHandler
PreparedStatement statement = null;
ResultSet rs = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement("SELECT id FROM auto_announcements ORDER BY id");
rs = statement.executeQuery();
@@ -265,7 +265,7 @@ public class AutoAnnouncementHandler
{
final AutoAnnouncementInstance announcementInst = _registeredAnnouncements.get(id);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM auto_announcements WHERE id=?");
statement.setInt(1, announcementInst.getDefaultId());

View File

@@ -64,7 +64,7 @@ public class AutoChatHandler implements SpawnListener
{
int numLoaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM auto_chat ORDER BY groupId ASC");
final ResultSet rs = statement.executeQuery();

View File

@@ -176,7 +176,7 @@ public class AdminAio implements IAdminCommandHandler
_player.setEndTime("aio", days);
_player.getStat().addExp(_player.getStat().getExpForLevel(81));
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET aio=1, aio_end=? WHERE obj_id=?");
statement.setLong(1, _player.getAioEndTime());
@@ -223,7 +223,7 @@ public class AdminAio implements IAdminCommandHandler
_player.setAio(false);
_player.setAioEndTime(0);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET Aio=0, Aio_end=0 WHERE obj_id=?");
statement.setInt(1, _player.getObjectId());

View File

@@ -303,7 +303,7 @@ public class AdminBan implements IAdminCommandHandler
value = 0;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET punish_level=?, punish_timer=? WHERE char_name=?");
statement.setInt(1, level);
@@ -339,7 +339,7 @@ public class AdminBan implements IAdminCommandHandler
private void jailOfflinePlayer(L2PcInstance activeChar, String name, int delay)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
statement.setInt(1, -114356);
@@ -374,7 +374,7 @@ public class AdminBan implements IAdminCommandHandler
private void unjailOfflinePlayer(L2PcInstance activeChar, String name)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
statement.setInt(1, 17836);
@@ -439,7 +439,7 @@ public class AdminBan implements IAdminCommandHandler
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
statement.setInt(1, lvl);

View File

@@ -136,7 +136,7 @@ public class AdminDonator implements IAdminCommandHandler
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement(newDonator ? INSERT_DATA : DEL_DATA);

View File

@@ -795,7 +795,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void storeTradeList(int itemID, int price, int tradeListID, int order)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement("INSERT INTO merchant_buylists (`item_id`,`price`,`shop_id`,`order`) values (" + itemID + "," + price + "," + tradeListID + "," + order + ")");
stmt.execute();
@@ -809,7 +809,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void updateTradeList(int itemID, int price, int tradeListID, int order)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement("UPDATE merchant_buylists SET `price`='" + price + "' WHERE `shop_id`='" + tradeListID + "' AND `order`='" + order + "'");
stmt.execute();
@@ -823,7 +823,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void deleteTradeList(int tradeListID, int order)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement("DELETE FROM merchant_buylists WHERE `shop_id`='" + tradeListID + "' AND `order`='" + order + "'");
stmt.execute();
@@ -838,7 +838,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private int findOrderTradeList(int itemID, int price, int tradeListID)
{
int order = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement("SELECT * FROM merchant_buylists WHERE `shop_id`='" + tradeListID + "' AND `item_id` ='" + itemID + "' AND `price` = '" + price + "'");
ResultSet rs = stmt.executeQuery();
@@ -1243,7 +1243,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void showEditDropData(L2PcInstance activeChar, int npcId, int itemId, int category)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT mobId, itemId, min, max, category, chance FROM droplist WHERE mobId=" + npcId + " AND itemId=" + itemId + " AND category=" + category);
ResultSet dropData = statement.executeQuery();
@@ -1307,7 +1307,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void updateDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE droplist SET min=?, max=?, chance=? WHERE mobId=? AND itemId=? AND category=?");
statement.setInt(1, min);
@@ -1361,7 +1361,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void addDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO droplist(mobId, itemId, min, max, category, chance) values(?,?,?,?,?,?)");
statement.setInt(1, npcId);
@@ -1392,7 +1392,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void deleteDropData(L2PcInstance activeChar, int npcId, int itemId, int category)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (npcId > 0)
{
@@ -1433,7 +1433,7 @@ public class AdminEditNpc implements IAdminCommandHandler
npcData.clearAllDropData();
// get the drops
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
L2DropData dropData = null;
@@ -1556,7 +1556,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void showNpcSkillEdit(L2PcInstance activeChar, int npcId, int skillId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills WHERE npcid=" + npcId + " AND skillid=" + skillId);
final ResultSet skillData = statement.executeQuery();
@@ -1611,7 +1611,7 @@ public class AdminEditNpc implements IAdminCommandHandler
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE npcskills SET level=? WHERE npcid=? AND skillid=?");
statement.setInt(1, level);
@@ -1682,7 +1682,7 @@ public class AdminEditNpc implements IAdminCommandHandler
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("INSERT INTO npcskills(npcid, skillid, level) values(?,?,?)");
statement.setInt(1, npcId);
@@ -1710,7 +1710,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void deleteNpcSkillData(L2PcInstance activeChar, int npcId, int skillId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (npcId > 0)
{
@@ -1739,7 +1739,7 @@ public class AdminEditNpc implements IAdminCommandHandler
private void reLoadNpcSkillList(int npcId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
npcData.getSkills().clear();

View File

@@ -340,7 +340,7 @@ public class AdminMenu implements IAdminCommandHandler
private void setAccountAccessLevel(String player, L2PcInstance activeChar, int banLevel)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
String stmt = "SELECT account_name FROM characters WHERE char_name = ?";
PreparedStatement statement = con.prepareStatement(stmt);

View File

@@ -125,7 +125,7 @@ public class AdminNoble implements IAdminCommandHandler
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement(newNoble ? INSERT_DATA : DEL_DATA);

View File

@@ -69,7 +69,7 @@ public class AdminRepairChar implements IAdminCommandHandler
}
String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(cmd);
statement.setString(1, parts[1]);

View File

@@ -69,7 +69,7 @@ public class AdminWalker implements IAdminCommandHandler
{
_npcid = Integer.parseInt(parts[1]);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT `route_id` FROM `walker_routes` WHERE `npc_id` = " + _npcid + ";");
final ResultSet rset = statement.executeQuery();
@@ -151,7 +151,7 @@ public class AdminWalker implements IAdminCommandHandler
private void setPoint(int x, int y, int z)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -86,7 +86,7 @@ public class HeroCustomItem implements IItemHandler
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement stmt = con.prepareStatement(INSERT_DATA);

View File

@@ -61,7 +61,7 @@ public class ClanWarsList implements IUserCommandHandler
}
SystemMessage sm;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -76,7 +76,7 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
{
String result = "";
final String repCharAcc = activeChar.getAccountName();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT char_name FROM characters WHERE account_name=?");
statement.setString(1, repCharAcc);
@@ -104,7 +104,7 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
{
boolean result = false;
String repCharAcc = "";
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT account_name FROM characters WHERE char_name=?");
statement.setString(1, repairChar);
@@ -133,7 +133,7 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
boolean result = false;
int accessLevel = 0;
int repCharJail = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT accesslevel,punish_level FROM characters WHERE char_name=?");
statement.setString(1, repairChar);
@@ -162,7 +162,7 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
{
boolean result = false;
int repCharKarma = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT karma FROM characters WHERE char_name=?");
statement.setString(1, repairChar);
@@ -198,7 +198,7 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
private void repairBadCharacter(String charName)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("SELECT obj_Id FROM characters WHERE char_name=?");

View File

@@ -220,7 +220,7 @@ public class Wedding implements IVoicedCommandHandler
// check if target has player on friendlist
/*
* boolean FoundOnFriendList = false; int objectId; Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(false); PreparedStatement statement; statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id=?"); statement.setInt(1,
* boolean FoundOnFriendList = false; int objectId; Connection con = null; try { con = L2DatabaseFactory.getConnection(false); PreparedStatement statement; statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id=?"); statement.setInt(1,
* ptarget.getObjectId()); ResultSet rset = statement.executeQuery(); while(rset.next()) { objectId = rset.getInt("friend_id"); if(objectId == activeChar.getObjectId()) { FoundOnFriendList = true; } } } catch(Exception e) { if(Config.ENABLE_ALL_EXCEPTIONS) e.printStackTrace();
* LOGGER.warning( "could not read friend data:" + e); } finally { CloseUtil.close(con); con = null; }
*/

View File

@@ -42,7 +42,7 @@ public class CompactionIDFactory extends IdFactory
_curOID = FIRST_OID;
_freeSize = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final int[] tmp_obj_ids = extractUsedObjectIDTable();

View File

@@ -128,7 +128,7 @@ public abstract class IdFactory
*/
private void setAllCharacterOffline()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final Statement s2 = con.createStatement();
s2.executeUpdate("update characters set online=0");
@@ -146,7 +146,7 @@ public abstract class IdFactory
*/
private void cleanUpDB()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
int cleanCount = 0;
final Statement stmt = con.createStatement();
@@ -202,7 +202,7 @@ public abstract class IdFactory
*/
protected int[] extractUsedObjectIDTable() throws SQLException
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// create a temporary table
final Statement s = con.createStatement();

View File

@@ -46,7 +46,7 @@ public class StackIDFactory extends IdFactory
_curOID = FIRST_OID;
_tempOID = FIRST_OID;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final int[] tmp_obj_ids = extractUsedObjectIDTable();
if (tmp_obj_ids.length > 0)

View File

@@ -132,7 +132,7 @@ public class AuctionManager
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -208,7 +208,7 @@ public class AuctionManager
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("INSERT INTO `auction` VALUES " + ITEM_INIT_DATA[i]);

View File

@@ -162,7 +162,7 @@ public class AutoSaveManager
/*
* Perform the clean here instead of every time that the skills are saved in order to do it in once step because if skill have 0 reuse delay doesn't affect the game, just makes the table grows bigger
*/
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("DELETE FROM character_skills_save WHERE reuse_delay=0 && restore_type=1");

View File

@@ -104,7 +104,7 @@ public class CastleManager
private final void load()
{
LOGGER.info("Initializing CastleManager");
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("Select id from castle order by id");
final ResultSet rs = statement.executeQuery();
@@ -351,7 +351,7 @@ public class CastleManager
}
// else offline-player circlet removal
PreparedStatement statement = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement("DELETE FROM items WHERE owner_id = ? and item_id = ?");
statement.setInt(1, member.getObjectId());

View File

@@ -196,7 +196,7 @@ public class CastleManorManager
{
ResultSet rs = null;
PreparedStatement statement = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
for (Castle castle : CastleManager.getInstance().getCastles())
{

View File

@@ -64,7 +64,7 @@ public class ClanHallManager
private final void load()
{
LOGGER.info("Initializing ClanHallManager");
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
int id, ownerId, lease, grade = 0;
String Name, Desc, Location;

View File

@@ -63,7 +63,7 @@ public class CoupleManager
// Method - Private
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;

View File

@@ -186,7 +186,7 @@ public class CursedWeaponsManager
private final void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT itemId, playerId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons");
ResultSet rset = statement.executeQuery();
@@ -223,7 +223,7 @@ public class CursedWeaponsManager
private final void controlPlayers()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = null;
ResultSet rset = null;
@@ -411,7 +411,7 @@ public class CursedWeaponsManager
public static void removeFromDb(int itemId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
statement.setInt(1, itemId);

View File

@@ -103,7 +103,7 @@ public final class CustomNpcInstanceManager
"SELECT spawn,template,name,title,class_id,female,hair_style,hair_color,face,name_color,title_color, noble,hero,pvp,karma,wpn_enchant,right_hand,left_hand,gloves,chest,legs,feet,hair,hair2, pledge,cw_level,clan_id,ally_id,clan_crest,ally_crest,rnd_class,rnd_appearance,rnd_weapon,rnd_armor,max_rnd_enchant FROM npc_to_pc_polymorph",
};
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
int count = 0;
for (String selectQuery : SQL_ITEM_SELECTS)
@@ -286,7 +286,7 @@ public final class CustomNpcInstanceManager
{
String Query = "REPLACE INTO npc_to_pc_polymorph VALUES spawn,template,name,title,class_id,female,hair_style,hair_color,face,name_color,title_color, noble,hero,pvp,karma,wpn_enchant,right_hand,left_hand,gloves,chest,legs,feet,hair,hair2, pledge,cw_level,clan_id,ally_id,clan_crest,ally_crest,rnd_class,rnd_appearance,rnd_weapon,rnd_armor,max_rnd_enchant FROM npc_to_pc_polymorph";
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(Query);
ResultSet rset = statement.executeQuery();

View File

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

View File

@@ -87,7 +87,7 @@ public class FishingChampionshipManager
{
_enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(SELECT);
ResultSet rs = statement.executeQuery();
@@ -367,7 +367,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

@@ -87,7 +87,7 @@ public class FortManager
// Method - Private
private final void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;

View File

@@ -121,7 +121,7 @@ public class FortSiegeGuardManager
*/
public void removeMerc(int npcId, int x, int y, int z)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("Delete From fort_siege_guards Where npcId = ? And x = ? AND y = ? AND z = ? AND isHired = 1");
statement.setInt(1, npcId);
@@ -143,7 +143,7 @@ public class FortSiegeGuardManager
*/
public void removeMercs()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("Delete From fort_siege_guards Where fortId = ? And isHired = 1");
statement.setInt(1, _fort.getFortId());
@@ -207,7 +207,7 @@ public class FortSiegeGuardManager
*/
private void loadSiegeGuard()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM fort_siege_guards Where fortId = ? ");
statement.setInt(1, _fort.getFortId());
@@ -258,7 +258,7 @@ public class FortSiegeGuardManager
*/
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 statement = con.prepareStatement("Insert Into fort_siege_guards (fortId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)");
statement.setInt(1, _fort.getFortId());

View File

@@ -144,7 +144,7 @@ public class FortSiegeManager
}
boolean register = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT clan_id FROM fortsiege_clans where clan_id=? and fort_id=?");
statement.setInt(1, clan.getClanId());

View File

@@ -567,7 +567,7 @@ public class FourSepulchersManager extends GrandBossManager
{
_mysteriousBoxSpawns.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = 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");
statement.setInt(1, 0);
@@ -651,7 +651,7 @@ public class FourSepulchersManager extends GrandBossManager
_physicalMonsters.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id");
statement1.setInt(1, 1);
@@ -716,7 +716,7 @@ public class FourSepulchersManager extends GrandBossManager
_magicalMonsters.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id");
statement1.setInt(1, 2);
@@ -782,7 +782,7 @@ public class FourSepulchersManager extends GrandBossManager
_archonSpawned.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id");
statement1.setInt(1, 5);
@@ -848,7 +848,7 @@ public class FourSepulchersManager extends GrandBossManager
_emperorsGraveNpcs.clear();
int loaded = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement1 = con.prepareStatement("SELECT Distinct key_npc_id FROM four_sepulchers_spawnlist Where spawntype = ? ORDER BY key_npc_id");
statement1.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

@@ -93,7 +93,7 @@ public class GrandBossManager
_bosses = new ConcurrentHashMap<>();
_storedInfo = new ConcurrentHashMap<>();
_bossStatus = new ConcurrentHashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT * from grandboss_data ORDER BY boss_id");
final ResultSet rset = statement.executeQuery();
@@ -152,7 +152,7 @@ public class GrandBossManager
zones.put(zone.getId(), new CopyOnWriteArrayList<Integer>());
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT * from grandboss_list ORDER BY player_id");
final ResultSet rset = statement.executeQuery();
@@ -287,7 +287,7 @@ public class GrandBossManager
private void fastStoreToDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
for (Integer bossId : _storedInfo.keySet())
{
@@ -333,7 +333,7 @@ public class GrandBossManager
private void storeToDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement delete = con.prepareStatement(DELETE_GRAND_BOSS_LIST);
delete.executeUpdate();
@@ -406,7 +406,7 @@ public class GrandBossManager
private void updateDb(int bossId, boolean statusOnly)
{
PreparedStatement statement = null;
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

@@ -83,7 +83,7 @@ public class ItemsOnGroundManager
// if DestroyPlayerDroppedItem was previously false, items curently protected will be added to ItemsAutoDestroy
if (Config.DESTROY_DROPPED_PLAYER_ITEM)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
String str = null;
if (!Config.DESTROY_EQUIPABLE_PLAYER_ITEM)
@@ -108,7 +108,7 @@ public class ItemsOnGroundManager
}
// Add items to world
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
Statement s = con.createStatement();
ResultSet result;
@@ -218,7 +218,7 @@ public class ItemsOnGroundManager
public void emptyTable()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement del = con.prepareStatement("delete from itemsonground");
del.execute();
@@ -255,7 +255,7 @@ public class ItemsOnGroundManager
continue; // Cursed Items not saved to ground, prevent double save
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("insert into itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) values(?,?,?,?,?,?,?,?,?)");
statement.setInt(1, item.getObjectId());

View File

@@ -688,7 +688,7 @@ public class MercTicketManager
private final void load()
{
// load merc tickets into the world
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;

View File

@@ -46,7 +46,7 @@ public class RaidBossPointsManager
{
_list = new HashMap<>();
final List<Integer> _chars = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM `character_raid_points`");
ResultSet rset = statement.executeQuery();
@@ -83,7 +83,7 @@ public class RaidBossPointsManager
public static final void updatePointsInDB(L2PcInstance player, int raidId, int points)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("REPLACE INTO character_raid_points (`charId`,`boss_id`,`points`) VALUES (?,?,?)");
@@ -154,7 +154,7 @@ public class RaidBossPointsManager
public static final void cleanUp()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("DELETE from character_raid_points WHERE charId > 0");

View File

@@ -79,7 +79,7 @@ public class RaidBossSpawnManager
_storedInfo.clear();
_schedules.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
Statement s = con.createStatement();
ResultSet rset = s.executeQuery("SELECT * FROM raidboss_spawnlist ORDER BY boss_id"))
{
@@ -283,7 +283,7 @@ public class RaidBossSpawnManager
if (storeInDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, spawnDat.getNpcId());
@@ -343,7 +343,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);
@@ -362,7 +362,7 @@ public class RaidBossSpawnManager
*/
void updateDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?"))
{
for (Integer bossId : _storedInfo.keySet())

View File

@@ -117,7 +117,7 @@ public 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 statement = con.prepareStatement("Delete From castle_siege_guards Where npcId = ? And x = ? AND y = ? AND z = ? AND isHired = 1");
statement.setInt(1, npcId);
@@ -139,7 +139,7 @@ public class SiegeGuardManager
*/
public void removeMercs()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("Delete From castle_siege_guards Where castleId = ? And isHired = 1");
statement.setInt(1, _castle.getCastleId());
@@ -196,7 +196,7 @@ public class SiegeGuardManager
*/
private void loadSiegeGuard()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT * FROM castle_siege_guards Where castleId = ? And isHired = ?");
statement.setInt(1, _castle.getCastleId());
@@ -255,7 +255,7 @@ public 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 statement = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)");
statement.setInt(1, _castle.getCastleId());

View File

@@ -166,7 +166,7 @@ public class SiegeManager
boolean register = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?");
statement.setInt(1, clan.getClanId());

View File

@@ -70,7 +70,7 @@ public class BlockList
{
List<Integer> list = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id = ? AND relation = 1");
statement.setInt(1, ObjId);
@@ -100,7 +100,7 @@ public class BlockList
private void updateInDB(int targetId, boolean state)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -114,7 +114,7 @@ public class CursedWeapon
// Remove from Db
LOGGER.info(_name + " being removed offline.");
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// Delete the item
PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
@@ -470,7 +470,7 @@ public class CursedWeapon
LOGGER.info("CursedWeapon: Saving data to disk.");
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// Delete previous datas
PreparedStatement statement = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");

View File

@@ -1630,7 +1630,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 FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY object_id DESC");
statement.setInt(1, getOwner().getObjectId());

View File

@@ -659,7 +659,7 @@ public abstract class ItemContainer
final int ownerid = getOwnerId();
final String baseLocation = getBaseLocation().name();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT object_id FROM items WHERE owner_id=? AND (loc=?) ORDER BY object_id DESC");
statement.setInt(1, ownerid);

View File

@@ -121,7 +121,7 @@ public final class L2Augmentation
private void saveAugmentationData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO augmentations (item_id,attributes,skill,level) VALUES (?,?,?,?)");
statement.setInt(1, _item.getObjectId());
@@ -155,7 +155,7 @@ public final class L2Augmentation
}
// delete the augmentation from the database
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM augmentations WHERE item_id=?");
statement.setInt(1, _item.getObjectId());

View File

@@ -759,7 +759,7 @@ public class L2Clan
public void updateClanInDB()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = 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=? WHERE clan_id=?");
statement.setInt(1, getLeaderId());
@@ -787,7 +787,7 @@ public class L2Clan
public void store()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO clan_data (clan_id,clan_name,clan_level,hasCastle,ally_id,ally_name,leader_id,crest_id,crest_large_id,ally_crest_id) values (?,?,?,?,?,?,?,?,?,?)");
statement.setInt(1, _clanId);
@@ -816,7 +816,7 @@ public class L2Clan
private void removeMemberInDatabase(L2ClanMember member, long clanJoinExpiryTime, long clanCreateExpiryTime)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = 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 obj_Id=?");
statement.setString(1, "");
@@ -849,7 +849,7 @@ public class L2Clan
private void restore()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
L2ClanMember member;
@@ -953,7 +953,7 @@ public class L2Clan
notice = notice.substring(0, MAX_NOTICE_LENGTH - 1);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET enabled=?,notice=? WHERE clan_id=?");
statement.setString(1, (enabled) ? "true" : "false");
@@ -1020,7 +1020,7 @@ public class L2Clan
intro = intro.substring(0, MAX_INTRODUCTION_LENGTH - 1);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET introduction=? WHERE clan_id=?");
statement.setString(1, intro);
@@ -1039,7 +1039,7 @@ public class L2Clan
private void restoreSkills()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT skill_id,skill_level FROM clan_skills WHERE clan_id=?");
statement.setInt(1, _clanId);
@@ -1116,7 +1116,7 @@ public class L2Clan
PreparedStatement statement;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (oldSkill != null)
{
@@ -1512,7 +1512,7 @@ public class L2Clan
private void restoreSubPledges()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT sub_pledge_id,name,leader_name FROM clan_subpledges WHERE clan_id=?");
statement.setInt(1, _clanId);
@@ -1623,7 +1623,7 @@ public class L2Clan
return null;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO clan_subpledges (clan_id,sub_pledge_id,name,leader_name) values (?,?,?,?)");
statement.setInt(1, _clanId);
@@ -1712,7 +1712,7 @@ public class L2Clan
public void updateSubPledgeInDB(int pledgeType)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE clan_subpledges SET leader_name=?, name=? WHERE clan_id=? AND sub_pledge_id=?");
statement.setString(1, getSubPledge(pledgeType).getLeaderName());
@@ -1736,7 +1736,7 @@ public class L2Clan
private void restoreRankPrivs()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT privs,rank,party FROM clan_privs WHERE clan_id=?");
statement.setInt(1, _clanId);
@@ -1792,7 +1792,7 @@ public class L2Clan
{
_privs.get(rank).setPrivs(privs);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE privs = ?");
statement.setInt(1, _clanId);
@@ -1829,7 +1829,7 @@ public class L2Clan
{
_privs.put(rank, new RankPrivs(rank, 0, privs));
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?)");
statement.setInt(1, _clanId);
@@ -1960,7 +1960,7 @@ public class L2Clan
if (storeInDb)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET auction_bid_at=? WHERE clan_id=?");
statement.setInt(1, id);
@@ -2521,7 +2521,7 @@ public class L2Clan
public void changeLevel(int level)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET clan_level = ? WHERE clan_id = ?");
statement.setInt(1, level);
@@ -2567,7 +2567,7 @@ public class L2Clan
public void setAllyCrest(int crestId)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
setAllyCrestId(crestId);
PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET ally_crest_id = ? WHERE clan_id = ?");

View File

@@ -213,7 +213,7 @@ public class L2ClanMember
public void updatePledgeType()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE characters SET subpledge=? WHERE obj_id=?");
statement.setLong(1, _pledgeType);
@@ -260,7 +260,7 @@ public class L2ClanMember
*/
public void updatePowerGrade()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET power_grade=? WHERE obj_id=?");
statement.setLong(1, _powerGrade);
@@ -545,7 +545,7 @@ public class L2ClanMember
public void saveApprenticeAndSponsor(int apprentice, int sponsor)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE characters SET apprentice=?,sponsor=? WHERE obj_Id=?");
statement.setInt(1, apprentice);

View File

@@ -292,7 +292,7 @@ public class L2TradeList
* update.addModifiedItem(playerItem); } else { L2World world = L2World.getInstance(); world.removeObject(playerItem); update.addRemovedItem(playerItem); world = null; } player.sendPacket(update); update = null; update = new InventoryUpdate(); if(recieverItem.getLastChange() ==
* L2ItemInstance.MODIFIED) { update.addModifiedItem(recieverItem); } else { update.addNewItem(recieverItem); } reciever.sendPacket(update); } // weight status update both player and reciever StatusUpdate su = new StatusUpdate(player.getObjectId()); su.addAttribute(StatusUpdate.CUR_LOAD,
* player.getCurrentLoad()); player.sendPacket(su); su = null; su = new StatusUpdate(reciever.getObjectId()); su.addAttribute(StatusUpdate.CUR_LOAD, reciever.getCurrentLoad()); reciever.sendPacket(su); su = null; playersInv = null; recieverInv = null; playerItem = null; recieverItem = null; temp
* = null; newitem = null; update = null; itemTable = null; } private void changePetItemObjectId(int oldObjectId, int newObjectId) { Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(false); PreparedStatement statement =
* = null; newitem = null; update = null; itemTable = null; } private void changePetItemObjectId(int oldObjectId, int newObjectId) { Connection con = null; try { con = L2DatabaseFactory.getConnection(false); PreparedStatement statement =
* con.prepareStatement("UPDATE pets SET item_obj_id = ? WHERE item_obj_id = ?"); statement.setInt(1, newObjectId); statement.setInt(2, oldObjectId); statement.executeUpdate(); DatabaseUtils.close(statement); statement = null; } catch(Exception e) {
* LOGGER.warning("could not change pet item object id: " + e); } finally { CloseUtil.close(con); con = null; } }
*/

View File

@@ -139,7 +139,7 @@ public class MacroList
private void registerMacroInDb(L2Macro macro)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO character_macroses (char_obj_id,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)");
statement.setInt(1, _owner.getObjectId());
@@ -192,7 +192,7 @@ public class MacroList
*/
private void deleteMacroFromDb(L2Macro macro)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM character_macroses WHERE char_obj_id=? AND id=?");
statement.setInt(1, _owner.getObjectId());
@@ -209,7 +209,7 @@ public class MacroList
public void restore()
{
_macroses.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT char_obj_id, id, icon, name, descr, acronym, commands FROM character_macroses WHERE char_obj_id=?");
statement.setInt(1, _owner.getObjectId());

View File

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

View File

@@ -80,7 +80,7 @@ public class ShortCuts
deleteShortCutFromDb(oldShortCut);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (char_obj_id,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)");
statement.setInt(1, _owner.getObjectId());
@@ -157,7 +157,7 @@ public class ShortCuts
*/
private void deleteShortCutFromDb(L2ShortCut shortcut)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=? AND slot=? AND page=? AND class_index=?");
statement.setInt(1, _owner.getObjectId());
@@ -176,7 +176,7 @@ public class ShortCuts
public void restore()
{
_shortCuts.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT char_obj_id, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE char_obj_id=? AND class_index=?");
statement.setInt(1, _owner.getObjectId());

View File

@@ -177,7 +177,7 @@ public class L2BoxInstance extends L2NpcInstance
public boolean hasAccess(String player)
{
boolean result = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement st = con.prepareStatement("SELECT spawn, charname FROM boxaccess WHERE charname=? AND spawn=?");
st.setString(1, player);
@@ -202,7 +202,7 @@ public class L2BoxInstance extends L2NpcInstance
public List<String> getAccess()
{
final List<String> acl = new ArrayList<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement st = con.prepareStatement(LIST_GRANT);
st.setInt(1, getSpawn().getId());
@@ -225,7 +225,7 @@ public class L2BoxInstance extends L2NpcInstance
public boolean grantAccess(String player, boolean what)
{
boolean result = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
String _query;
if (what)
@@ -387,7 +387,7 @@ public class L2BoxInstance extends L2NpcInstance
private Set<L2BoxItem> getItems(String drawer)
{
final Set<L2BoxItem> it = new HashSet<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT id, spawn, npcid, drawer, itemid, name, count, enchant FROM boxes where spawn=? and npcid=? and drawer=?");
statement.setInt(1, getSpawn().getId());
@@ -415,7 +415,7 @@ public class L2BoxInstance extends L2NpcInstance
* Integer.parseInt(part[0].substring(1)); int count = Integer.parseInt(part[1]); if (count <= 0) continue; int realCount = player.getInventory().getItemByItemId(id).getCount(); if (count < realCount) realCount = count; L2ItemInstance item = player.getInventory().destroyItemByItemId("Box",
* id, realCount, player, this); // other than previous l2j, destroyItemByItemId does not return the count destroyed // and we cannot just use the returned item as we cannot change the count L2ItemInstance newItem = ItemTable.getInstance().createItem(id); newItem.setCount(realCount);
* newItem.setEnchantLevel(item.getEnchantLevel()); putItemInBox(player, drawername, newItem); } catch (Exception e) { LOGGER.fine("putInBox "+command+" failed: "+e); } } } private void putItemInBox(L2PcInstance player, String drawer, L2ItemInstance item) { String charname =
* player.getName(); java.sql.Connection con = null; int foundId = 0; int foundCount = 0; try { con = L2DatabaseFactory.getInstance().getConnection(false); if (item.isStackable()) { PreparedStatement st2 =
* player.getName(); java.sql.Connection con = null; int foundId = 0; int foundCount = 0; try { con = L2DatabaseFactory.getConnection(false); if (item.isStackable()) { PreparedStatement st2 =
* con.prepareStatement("SELECT id,count FROM boxes where spawn=? and npcid=? and drawer=? and itemid=?"); st2.setInt(1, getSpawn().getId()); st2.setInt(2, getNpcId()); st2.setString(3, drawer); st2.setInt(4, item.getItemId()); ResultSet rs = st2.executeQuery(); if (rs.next()) { foundId =
* rs.getInt("id"); foundCount = rs.getInt("count"); } rs.close(); st2.close(); } if (foundCount == 0) { PreparedStatement statement = con.prepareStatement("INSERT INTO boxes (spawn,npcid,drawer,itemid,name,count,enchant) VALUES(?,?,?,?,?,?,?)"); statement.setInt(1, getSpawn().getId());
* statement.setInt(2, getNpcId()); statement.setString(3, drawer); statement.setInt(4, item.getItemId()); statement.setString(5, item.getItem().getName()); statement.setInt(6, item.getCount()); statement.setInt(7, item.getEnchantLevel()); statement.execute(); statement.close(); } else {
@@ -429,7 +429,7 @@ public class L2BoxInstance extends L2NpcInstance
* NOTE: Item storing in box is currently not implemented String[] cmd = command.split(","); if (cmd.length<=1) return; String drawername = cmd[0]; L2BoxItem bi = null; for (int i = 1; i < cmd.length; i++) { String[] part = cmd[i].split(" "); if (part == null || part.length < 2) continue;
* try { int id = Integer.parseInt(part[0].substring(1)); int count = Integer.parseInt(part[1]); if (count <= 0) continue; L2ItemInstance item = ItemTable.getInstance().createItem(id); item.setCount(count); bi = takeItemOutBox(player, drawername, item); if (bi.count > 0) {
* item.setCount(bi.count); item.setEnchantLevel(bi.enchant); player.getInventory().addItem("Box", item, player, this); } } catch (Exception e) { LOGGER.fine("takeOutBox "+command+" failed: "+e); } } } private L2BoxItem takeItemOutBox(L2PcInstance player, String drawer, L2ItemInstance item)
* { String charname = player.getName(); java.sql.Connection con = null; L2BoxItem bi = new L2BoxItem(); bi.count = 0; try { con = L2DatabaseFactory.getInstance().getConnection(false); PreparedStatement statement =
* { String charname = player.getName(); java.sql.Connection con = null; L2BoxItem bi = new L2BoxItem(); bi.count = 0; try { con = L2DatabaseFactory.getConnection(false); PreparedStatement statement =
* con.prepareStatement("SELECT id,count,enchant FROM boxes WHERE spawn=? AND npcid=? AND drawer=? AND itemid=? AND count>=?"); statement.setInt(1, getSpawn().getId()); statement.setInt(2, getNpcId()); statement.setString(3, drawer); statement.setInt(4, item.getItemId()); statement.setInt(5,
* item.getCount()); ResultSet rs = statement.executeQuery(); while (rs.next()) { if (rs.getInt("count") == item.getCount()) { bi.count = item.getCount(); bi.itemid = item.getItemId(); bi.enchant = rs.getInt("enchant"); PreparedStatement st2 =
* con.prepareStatement("DELETE FROM boxes WHERE id=?"); st2.setInt(1, rs.getInt("id")); st2.execute(); st2.close(); break; } if (rs.getInt("count") > item.getCount()) { bi.count = item.getCount(); bi.itemid = item.getItemId(); bi.enchant = rs.getInt("enchant"); PreparedStatement st2 =

View File

@@ -1167,7 +1167,7 @@ public final class L2ItemInstance extends L2Object
public static L2ItemInstance restoreFromDb(int objectId)
{
L2ItemInstance inst = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT owner_id, object_id, item_id, count, enchant_level, loc, loc_data, price_sell, price_buy, custom_type1, custom_type2, mana_left FROM items WHERE object_id = ?");
statement.setInt(1, objectId);
@@ -1368,7 +1368,7 @@ public final class L2ItemInstance extends L2Object
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,price_sell=?,price_buy=?,custom_type1=?,custom_type2=?,mana_left=? WHERE object_id = ?");
statement.setInt(1, _ownerId);
@@ -1413,7 +1413,7 @@ public final class L2ItemInstance extends L2Object
assert !_existsInDb && (getObjectId() != 0);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,price_sell,price_buy,object_id,custom_type1,custom_type2,mana_left) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
statement.setInt(1, _ownerId);
@@ -1469,7 +1469,7 @@ public final class L2ItemInstance extends L2Object
_augmentation.deleteAugmentationData();
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE object_id=?");
statement.setInt(1, getObjectId());

View File

@@ -1362,7 +1362,7 @@ public final class L2PcInstance extends L2Playable
public int getVotePoints()
{
int votePoints = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("select votePoints from accounts where login=?");
@@ -1388,7 +1388,7 @@ public final class L2PcInstance extends L2Playable
*/
public void setVotePoints(int points)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("update accounts set votePoints=" + points + " where login='" + _accountName + "'");
@@ -1407,7 +1407,7 @@ public final class L2PcInstance extends L2Playable
public int getVoteTime()
{
int lastVote = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("select lastVote from accounts where login=?");
@@ -2851,7 +2851,7 @@ public final class L2PcInstance extends L2Playable
{
if (Config.ALT_RECOMMEND)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(ADD_CHAR_RECOM);
statement.setInt(1, getObjectId());
@@ -8301,7 +8301,7 @@ public final class L2PcInstance extends L2Playable
String killer = PlayerWhoKilled.getName();
String killed = getName();
int kills = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT kills FROM pkkills WHERE killerId=? AND killedId=?");
statement.setString(1, killer);
@@ -8323,7 +8323,7 @@ public final class L2PcInstance extends L2Playable
{
kills++;
String UPDATE_PKKILLS = "UPDATE pkkills SET kills=? WHERE killerId=? AND killedId=?";
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(UPDATE_PKKILLS);
statement.setInt(1, kills);
@@ -8342,7 +8342,7 @@ public final class L2PcInstance extends L2Playable
else
{
String ADD_PKKILLS = "INSERT INTO pkkills (killerId,killedId,kills) VALUES (?,?,?)";
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(ADD_PKKILLS);
statement.setString(1, killer);
@@ -9779,7 +9779,7 @@ public final class L2PcInstance extends L2Playable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE obj_id=?");
statement.setInt(1, isOnline());
@@ -9799,7 +9799,7 @@ public final class L2PcInstance extends L2Playable
*/
public void updateIsIn7sDungeonStatus()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("UPDATE characters SET isIn7sDungeon=?, lastAccess=? WHERE obj_id=?");
statement.setInt(1, isIn7sDungeon() ? 1 : 0);
@@ -9819,7 +9819,7 @@ public final class L2PcInstance extends L2Playable
*/
public void updateFirstLog()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET first_log=? WHERE obj_id=?");
@@ -9852,7 +9852,7 @@ public final class L2PcInstance extends L2Playable
{
boolean output = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,acc,crit,evasion,mAtk,mDef,mSpd,pAtk,pDef,pSpd,runSpd,walkSpd,str,con,dex,_int,men,wit,face,hairStyle,hairColor,sex,movement_multiplier,attack_speed_multiplier,colRad,colHeight,exp,sp,karma,pvpkills,pkkills,clanid,maxload,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date,name_color,title_color,aio,aio_end) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
@@ -9952,7 +9952,7 @@ public final class L2PcInstance extends L2Playable
double curCp = 0;
double curMp = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER);
statement.setInt(1, objectId);
@@ -10270,7 +10270,7 @@ public final class L2PcInstance extends L2Playable
*/
private static boolean restoreSubClassData(L2PcInstance player)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_SUBCLASSES);
statement.setInt(1, player.getObjectId());
@@ -10348,7 +10348,7 @@ public final class L2PcInstance extends L2Playable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM character_recipebook WHERE char_id=?");
statement.setInt(1, getObjectId());
@@ -10388,7 +10388,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreRecipeBook()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT id, type FROM character_recipebook WHERE char_id=?");
statement.setInt(1, getObjectId());
@@ -10548,7 +10548,7 @@ public final class L2PcInstance extends L2Playable
*/
private synchronized void storeCharBase()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
// Get the exp, level, and sp of base class to store in base table
final int currentClassIndex = getClassIndex();
@@ -10668,7 +10668,7 @@ public final class L2PcInstance extends L2Playable
*/
private synchronized void storeCharSub()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -10704,7 +10704,7 @@ public final class L2PcInstance extends L2Playable
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
// Delete all current stored effects for char to avoid dupe
@@ -10884,7 +10884,7 @@ public final class L2PcInstance extends L2Playable
// Remove a skill from the L2Character and its Func objects from calculator set of the L2Character
final L2Skill oldSkill = super.removeSkill(skill);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -10933,7 +10933,7 @@ public final class L2PcInstance extends L2Playable
classIndex = newClassIndex;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = null;
if ((oldSkill != null) && (newSkill != null))
@@ -11097,7 +11097,7 @@ public final class L2PcInstance extends L2Playable
*/
public synchronized void restoreSkills()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (!Config.KEEP_SUBCLASS_SKILLS)
{
@@ -11173,7 +11173,7 @@ public final class L2PcInstance extends L2Playable
*/
public void restoreEffects(boolean activateEffects)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rset;
@@ -11288,7 +11288,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreHenna()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS);
statement.setInt(1, getObjectId());
@@ -11343,7 +11343,7 @@ public final class L2PcInstance extends L2Playable
*/
private void restoreRecom()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_RECOMS);
statement.setInt(1, getObjectId());
@@ -11409,7 +11409,7 @@ public final class L2PcInstance extends L2Playable
L2HennaInstance henna = _henna[slot];
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA);
statement.setInt(1, getObjectId());
@@ -11467,7 +11467,7 @@ public final class L2PcInstance extends L2Playable
// Calculate Henna modifiers of this L2PcInstance
recalcHennaStats();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA);
statement.setInt(1, getObjectId());
@@ -13790,7 +13790,7 @@ public final class L2PcInstance extends L2Playable
final String HERO_COUNT = "SELECT count FROM heroes WHERE char_name=?";
int _count = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(HERO_COUNT);
statement.setString(1, getName());
@@ -14383,7 +14383,7 @@ public final class L2PcInstance extends L2Playable
boolean output = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS);
statement.setInt(1, getObjectId());
@@ -14468,7 +14468,7 @@ public final class L2PcInstance extends L2Playable
boolean output = false;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -15085,7 +15085,7 @@ public final class L2PcInstance extends L2Playable
{
if (Config.ALT_RECOMMEND)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE_CHAR_RECOMS);
statement.setInt(1, getObjectId());
@@ -16453,7 +16453,7 @@ public final class L2PcInstance extends L2Playable
{
_friendList.clear();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id = ? AND relation = 0");
statement.setInt(1, getObjectId());
@@ -17417,7 +17417,7 @@ public final class L2PcInstance extends L2Playable
int donator = 0;
long hero_end = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(STATUS_DATA_GET);
statement.setInt(1, getObjectId());
@@ -19129,7 +19129,7 @@ public final class L2PcInstance extends L2Playable
{
return;
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET sex=? WHERE obj_Id=?");
statement.setInt(1, player.getAppearance().getSex() ? 1 : 0);

View File

@@ -871,7 +871,7 @@ public class L2PetInstance extends L2Summon
}
// pet control item no longer exists, delete the pet from the db
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?");
statement.setInt(1, _controlItemId);
@@ -977,7 +977,7 @@ public class L2PetInstance extends L2Summon
{
L2PetInstance pet = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (template.type.compareToIgnoreCase("L2BabyPet") == 0)
{
@@ -1048,7 +1048,7 @@ public class L2PetInstance extends L2Summon
req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,karma=?,pkkills=?,fed=? WHERE item_obj_id = ?";
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(req);
statement.setString(1, getName());

View File

@@ -266,7 +266,7 @@ public class Auction
*/
private void load()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -308,7 +308,7 @@ public class Auction
_highestBidderName = "";
_highestBidderMaxBid = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -373,7 +373,7 @@ public class Auction
*/
private void saveAuctionDate()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("Update auction set endDate = ? where id = ?");
statement.setLong(1, _endDate);
@@ -461,7 +461,7 @@ public class Auction
*/
private void updateInDB(L2PcInstance bidder, int bid)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -523,7 +523,7 @@ public class Auction
*/
private void removeBids()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -559,7 +559,7 @@ public class Auction
public void deleteAuctionFromDB()
{
AuctionManager.getInstance().getAuctions().remove(this);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("DELETE FROM auction WHERE itemId=?");
@@ -623,7 +623,7 @@ public class Auction
*/
public synchronized void cancelBid(int bidder)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -660,7 +660,7 @@ public class Auction
public void confirmAuction()
{
AuctionManager.getInstance().getAuctions().add(this);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");

View File

@@ -332,7 +332,7 @@ public class ClanHall
*/
public void dbSave(boolean newFunction)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -728,7 +728,7 @@ public class ClanHall
*/
private void loadFunctions()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -757,7 +757,7 @@ public class ClanHall
public void removeFunction(int functionType)
{
_functions.remove(functionType);
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement("DELETE FROM clanhall_functions WHERE hall_id=? AND type=?");
@@ -834,7 +834,7 @@ public class ClanHall
*/
public void updateDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -969,7 +969,7 @@ public class ClanHall
*/
private void loadDoor()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("Select * from castle_door where castleId = ?");
statement.setInt(1, _clanHallId);

View File

@@ -87,7 +87,7 @@ public class Hero
{
_heroes = new HashMap<>();
_completeHeroes = new HashMap<>();
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = null;
PreparedStatement statement2 = null;
@@ -379,7 +379,7 @@ public class Hero
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = null;
ResultSet rset = null;
@@ -419,7 +419,7 @@ public class Hero
PreparedStatement statement = null;
PreparedStatement statement2 = null;
ResultSet rset2 = null;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
if (setDefault)
{
@@ -502,7 +502,7 @@ public class Hero
private void deleteItemsInDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE_ITEMS);
statement.execute();

View File

@@ -420,7 +420,7 @@ public class L2Rebirth
final int playerId = player.getObjectId();
int rebirthCount = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
ResultSet rset;
PreparedStatement statement = con.prepareStatement("SELECT * FROM `rebirth_manager` WHERE playerId = ?");
@@ -448,7 +448,7 @@ public class L2Rebirth
*/
public void storePlayerBirth(L2PcInstance player)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO `rebirth_manager` (playerId,rebirthCount) VALUES (?,1)");
statement.setInt(1, player.getObjectId());
@@ -469,7 +469,7 @@ public class L2Rebirth
*/
public void updatePlayerBirth(L2PcInstance player, int newRebirthCount)
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final int playerId = player.getObjectId();

View File

@@ -49,7 +49,7 @@ public class Wedding
{
_Id = coupleId;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -95,7 +95,7 @@ public class Wedding
_weddingDate = Calendar.getInstance();
_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -122,7 +122,7 @@ public class Wedding
public void marry(int type)
{
_type = type;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
@@ -147,7 +147,7 @@ public class Wedding
public void divorce()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -1152,7 +1152,7 @@ public class CTF implements EventTask
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
statement.setInt(1, _npcX);
@@ -1859,7 +1859,7 @@ public class CTF implements EventTask
_maxPlayers = 0;
_intervalBetweenMatches = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -1941,7 +1941,7 @@ public class CTF implements EventTask
*/
public static void saveData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -1078,7 +1078,7 @@ public class DM implements EventTask
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
statement.setInt(1, _npcX);
@@ -1665,7 +1665,7 @@ public class DM implements EventTask
_playerY = 0;
_playerZ = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -1710,7 +1710,7 @@ public class DM implements EventTask
*/
public static void saveData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -46,7 +46,7 @@ public class EventPoint
private void loadFromDB()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement st = con.prepareStatement("Select * From char_points where charId = ?");
st.setInt(1, _activeChar.getObjectId());
@@ -67,7 +67,7 @@ public class EventPoint
private void saveToDb()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement st = con.prepareStatement("Update char_points Set points = ? Where charId = ?");
st.setInt(1, _points);

View File

@@ -95,7 +95,7 @@ public class Lottery
public void increasePrize(int count)
{
_prize += count;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
statement = con.prepareStatement(UPDATE_PRICE);
@@ -132,7 +132,7 @@ public class Lottery
public void run()
{
PreparedStatement statement;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement(SELECT_LAST_LOTTERY);
ResultSet rset = statement.executeQuery();
@@ -215,7 +215,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())
{
statement = con.prepareStatement(INSERT_LOTTERY);
statement.setInt(1, 1);
@@ -324,7 +324,7 @@ public class Lottery
int count4 = 0;
PreparedStatement statement;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement(SELECT_LOTTERY_ITEM);
statement.setInt(1, _number);
@@ -441,7 +441,7 @@ public class Lottery
Announcements.getInstance().announceToAll(sm);
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement(UPDATE_LOTTERY);
statement.setInt(1, _prize);
@@ -516,7 +516,7 @@ public class Lottery
};
PreparedStatement statement;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
statement = con.prepareStatement(SELECT_LOTTERY_TICKET);
statement.setInt(1, id);

View File

@@ -1085,7 +1085,7 @@ public class TvT implements EventTask
}
else
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
statement.setInt(1, _npcX);
@@ -1765,7 +1765,7 @@ public class TvT implements EventTask
_maxPlayers = 0;
_intervalBetweenMatchs = 0;
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;
ResultSet rs;
@@ -1837,7 +1837,7 @@ public class TvT implements EventTask
*/
public static void saveData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement;

View File

@@ -149,7 +149,7 @@ public class VIP
public static void setLoc()
{
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT endx,endy,endz FROM VIPinfo WHERE teamID = " + _team);
final ResultSet rset = statement.executeQuery();
@@ -167,7 +167,7 @@ public class VIP
LOGGER.info("Could not check End LOC for team" + _team + " got: " + e.getMessage());
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT startx,starty,startz FROM VIPinfo WHERE teamID = " + _team);
final ResultSet rset = statement.executeQuery();

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