Refactored DatabaseFactory.
This commit is contained in:
@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.AuctionItemType;
|
||||
@ -162,7 +162,7 @@ public class Auction
|
||||
/** Load auctions */
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
@ -197,7 +197,7 @@ public class Auction
|
||||
_highestBidderName = "";
|
||||
_highestBidderMaxBid = 0;
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
@ -246,7 +246,7 @@ public class Auction
|
||||
/** Save Auction Data End */
|
||||
private void saveAuctionDate()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("Update auction set endDate = ? where id = ?"))
|
||||
{
|
||||
ps.setLong(1, _endDate);
|
||||
@ -344,7 +344,7 @@ public class Auction
|
||||
*/
|
||||
private void updateInDB(L2PcInstance bidder, long bid)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
if (_bidders.get(bidder.getClanId()) != null)
|
||||
{
|
||||
@ -401,7 +401,7 @@ public class Auction
|
||||
/** Remove bids */
|
||||
private void removeBids()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
@ -434,7 +434,7 @@ public class Auction
|
||||
public void deleteAuctionFromDB()
|
||||
{
|
||||
ClanHallAuctionManager.getInstance().getAuctions().remove(this);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
|
||||
{
|
||||
ps.setInt(1, _itemId);
|
||||
@ -490,7 +490,7 @@ public class Auction
|
||||
*/
|
||||
public synchronized void cancelBid(int bidder)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
@ -519,7 +519,7 @@ public class Auction
|
||||
public void confirmAuction()
|
||||
{
|
||||
ClanHallAuctionManager.getInstance().getAuctions().add(this);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
|
@ -29,7 +29,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.CastleData;
|
||||
@ -219,7 +219,7 @@ public final class Castle extends AbstractResidence
|
||||
|
||||
public void dbSave()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -360,7 +360,7 @@ public final class Castle extends AbstractResidence
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setLong(1, getTreasury());
|
||||
@ -622,7 +622,7 @@ public final class Castle extends AbstractResidence
|
||||
@Override
|
||||
protected void load()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
|
||||
PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
|
||||
{
|
||||
@ -669,7 +669,7 @@ public final class Castle extends AbstractResidence
|
||||
/** Load All Functions */
|
||||
private void loadFunctions()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -694,7 +694,7 @@ public final class Castle extends AbstractResidence
|
||||
public void removeFunction(int functionType)
|
||||
{
|
||||
_function.remove(functionType);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -769,7 +769,7 @@ public final class Castle extends AbstractResidence
|
||||
// This method loads castle door upgrade data from database
|
||||
private void loadDoorUpgrade()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -795,7 +795,7 @@ public final class Castle extends AbstractResidence
|
||||
door.setCurrentHp(door.getCurrentHp());
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -820,7 +820,7 @@ public final class Castle extends AbstractResidence
|
||||
|
||||
if (save)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, doorId);
|
||||
@ -847,7 +847,7 @@ public final class Castle extends AbstractResidence
|
||||
CastleManorManager.getInstance().resetManorData(getResidenceId());
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
// Need to remove has castle flag from clan_data, should be checked from castle table.
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?"))
|
||||
@ -1026,7 +1026,7 @@ public final class Castle extends AbstractResidence
|
||||
|
||||
public void updateShowNpcCrest()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setString(1, String.valueOf(getShowNpcCrest()));
|
||||
@ -1070,7 +1070,7 @@ public final class Castle extends AbstractResidence
|
||||
{
|
||||
_ticketBuyCount = count;
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _ticketBuyCount);
|
||||
@ -1093,7 +1093,7 @@ public final class Castle extends AbstractResidence
|
||||
{
|
||||
if (save)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1120,7 +1120,7 @@ public final class Castle extends AbstractResidence
|
||||
ts.setUpgradeLevel(0);
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1210,7 +1210,7 @@ public final class Castle extends AbstractResidence
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setString(1, side.toString());
|
||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
@ -185,7 +185,7 @@ public abstract class ClanHall
|
||||
|
||||
public void dbSave()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO clanhall_functions (hall_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
@ -443,7 +443,7 @@ public abstract class ClanHall
|
||||
/** Load All Functions */
|
||||
protected void loadFunctions()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM clanhall_functions WHERE hall_id = ?"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
@ -468,7 +468,7 @@ public abstract class ClanHall
|
||||
public void removeFunction(int functionType)
|
||||
{
|
||||
_functions.remove(functionType);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_functions WHERE hall_id=? AND type=?"))
|
||||
{
|
||||
ps.setInt(1, getId());
|
||||
|
@ -23,7 +23,7 @@ import java.util.Calendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
@ -45,7 +45,7 @@ public class Couple
|
||||
{
|
||||
_Id = coupleId;
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _Id);
|
||||
@ -85,7 +85,7 @@ public class Couple
|
||||
_weddingDate = Calendar.getInstance();
|
||||
_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
|
||||
{
|
||||
_Id = IdFactory.getInstance().getNextId();
|
||||
@ -105,7 +105,7 @@ public class Couple
|
||||
|
||||
public void marry()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?"))
|
||||
{
|
||||
ps.setBoolean(1, true);
|
||||
@ -123,7 +123,7 @@ public class Couple
|
||||
|
||||
public void divorce()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?"))
|
||||
{
|
||||
ps.setInt(1, _Id);
|
||||
|
@ -34,7 +34,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.FortUpdater;
|
||||
import com.l2jmobius.gameserver.FortUpdater.UpdaterType;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
@ -219,7 +219,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
public void dbSave()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -492,7 +492,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
public void saveFortVariables()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _supplyLvL);
|
||||
@ -559,7 +559,7 @@ public final class Fort extends AbstractResidence
|
||||
@Override
|
||||
protected void load()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -620,7 +620,7 @@ public final class Fort extends AbstractResidence
|
||||
/** Load All Functions */
|
||||
private void loadFunctions()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -645,7 +645,7 @@ public final class Fort extends AbstractResidence
|
||||
public void removeFunction(int functionType)
|
||||
{
|
||||
_function.remove(functionType);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -747,7 +747,7 @@ public final class Fort extends AbstractResidence
|
||||
// This method loads fort door upgrade data from database
|
||||
private void loadDoorUpgrade()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -767,7 +767,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
private void removeDoorUpgrade()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -781,7 +781,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, doorId);
|
||||
@ -810,7 +810,7 @@ public final class Fort extends AbstractResidence
|
||||
_lastOwnedTime.setTimeInMillis(0);
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, clanId);
|
||||
@ -1022,7 +1022,7 @@ public final class Fort extends AbstractResidence
|
||||
{
|
||||
_state = state;
|
||||
_castleId = castleId;
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, getFortState());
|
||||
@ -1154,7 +1154,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
private void initNpcs()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1185,7 +1185,7 @@ public final class Fort extends AbstractResidence
|
||||
private void initSiegeNpcs()
|
||||
{
|
||||
_siegeNpcs.clear();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1214,7 +1214,7 @@ public final class Fort extends AbstractResidence
|
||||
private void initNpcCommanders()
|
||||
{
|
||||
_npcCommanders.clear();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1246,7 +1246,7 @@ public final class Fort extends AbstractResidence
|
||||
_specialEnvoys.clear();
|
||||
_envoyCastles.clear();
|
||||
_availableCastles.clear();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading, castleId FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
|
@ -28,7 +28,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
@ -493,7 +493,7 @@ public class FortSiege implements Siegable
|
||||
/** Clear all registered siege clans from database for fort */
|
||||
public void clearSiegeClan()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?"))
|
||||
{
|
||||
ps.setInt(1, getFort().getResidenceId());
|
||||
@ -768,7 +768,7 @@ public class FortSiege implements Siegable
|
||||
private void removeSiegeClan(int clanId)
|
||||
{
|
||||
final String query = (clanId != 0) ? DELETE_FORT_SIEGECLANS_BY_CLAN_ID : DELETE_FORT_SIEGECLANS;
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(query))
|
||||
{
|
||||
ps.setInt(1, getFort().getResidenceId());
|
||||
@ -982,7 +982,7 @@ public class FortSiege implements Siegable
|
||||
private void loadSiegeClan()
|
||||
{
|
||||
getAttackerClans().clear();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?"))
|
||||
{
|
||||
ps.setInt(1, getFort().getResidenceId());
|
||||
@ -1043,7 +1043,7 @@ public class FortSiege implements Siegable
|
||||
/** Save siege date to database. */
|
||||
private void saveSiegeDate()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setLong(1, getSiegeDate().getTimeInMillis());
|
||||
@ -1067,7 +1067,7 @@ public class FortSiege implements Siegable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
|
||||
{
|
||||
ps.setInt(1, clan.getId());
|
||||
|
@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
@ -108,7 +108,7 @@ public class Hero
|
||||
HERO_DIARY.clear();
|
||||
HERO_MESSAGE.clear();
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s1 = con.createStatement();
|
||||
ResultSet rset = s1.executeQuery(GET_HEROES);
|
||||
PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
|
||||
@ -206,7 +206,7 @@ public class Hero
|
||||
*/
|
||||
public void loadMessage(int charId)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, charId);
|
||||
@ -228,7 +228,7 @@ public class Hero
|
||||
{
|
||||
final List<StatsSet> diary = new ArrayList<>();
|
||||
int diaryentries = 0;
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
|
||||
{
|
||||
ps.setInt(1, charId);
|
||||
@ -295,7 +295,7 @@ public class Hero
|
||||
int _losses = 0;
|
||||
int _draws = 0;
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
|
||||
{
|
||||
ps.setInt(1, charId);
|
||||
@ -692,7 +692,7 @@ public class Hero
|
||||
|
||||
public void updateHeroes(boolean setDefault)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
if (setDefault)
|
||||
{
|
||||
@ -823,7 +823,7 @@ public class Hero
|
||||
|
||||
public void setDiaryData(int charId, int action, int param)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, charId);
|
||||
@ -859,7 +859,7 @@ public class Hero
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
|
||||
{
|
||||
ps.setString(1, HERO_MESSAGE.get(charId));
|
||||
@ -874,7 +874,7 @@ public class Hero
|
||||
|
||||
private void deleteItemsInDb()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement s = con.createStatement())
|
||||
{
|
||||
s.executeUpdate(DELETE_ITEMS);
|
||||
|
@ -31,7 +31,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SiegeScheduleData;
|
||||
@ -771,7 +771,7 @@ public class Siege implements Siegable
|
||||
/** Clear all registered siege clans from database for castle */
|
||||
public void clearSiegeClan()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
|
||||
{
|
||||
ps.setInt(1, getCastle().getResidenceId());
|
||||
@ -799,7 +799,7 @@ public class Siege implements Siegable
|
||||
/** Clear all siege clans waiting for approval from database for castle */
|
||||
public void clearSiegeWaitingClan()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
|
||||
{
|
||||
ps.setInt(1, getCastle().getResidenceId());
|
||||
@ -1026,7 +1026,7 @@ public class Siege implements Siegable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, getCastle().getResidenceId());
|
||||
@ -1291,7 +1291,7 @@ public class Siege implements Siegable
|
||||
/** Load siege clans. */
|
||||
private void loadSiegeClan()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
|
||||
{
|
||||
getAttackerClans().clear();
|
||||
@ -1402,7 +1402,7 @@ public class Siege implements Siegable
|
||||
_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setLong(1, getSiegeDate().getTimeInMillis());
|
||||
@ -1431,7 +1431,7 @@ public class Siege implements Siegable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||
@ -215,7 +215,7 @@ public final class AuctionableHall extends ClanHall
|
||||
@Override
|
||||
public final void updateDb()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
|
||||
{
|
||||
ps.setInt(1, getOwnerId());
|
||||
|
@ -28,7 +28,7 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
@ -91,7 +91,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
|
||||
public void loadAttackers()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
|
||||
{
|
||||
ps.setInt(1, _hall.getId());
|
||||
@ -113,7 +113,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
|
||||
public final void saveAttackers()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
|
||||
{
|
||||
ps.setInt(1, _hall.getId());
|
||||
@ -145,7 +145,7 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
|
||||
if (_guards == null)
|
||||
{
|
||||
_guards = new ArrayList<>();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SQL_LOAD_GUARDS))
|
||||
{
|
||||
ps.setInt(1, _hall.getId());
|
||||
|
@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
|
||||
import java.util.Calendar;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.SiegeClanType;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2SiegeClan;
|
||||
@ -130,7 +130,7 @@ public final class SiegableHall extends ClanHall
|
||||
@Override
|
||||
public final void updateDb()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SQL_SAVE))
|
||||
{
|
||||
ps.setInt(1, getOwnerId());
|
||||
|
Reference in New Issue
Block a user