Refactored DatabaseFactory.
This commit is contained in:
@@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
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.enums.ManorMode;
|
||||
import com.l2jmobius.gameserver.model.CropProcure;
|
||||
@@ -164,7 +164,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
|
||||
private final void loadDb()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement stProduction = con.prepareStatement("SELECT * FROM castle_manor_production WHERE castle_id=?");
|
||||
PreparedStatement stProcure = con.prepareStatement("SELECT * FROM castle_manor_procure WHERE castle_id=?"))
|
||||
{
|
||||
@@ -442,7 +442,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
_productionNext.put(castleId, list);
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ? AND next_period = 1");
|
||||
PreparedStatement ips = con.prepareStatement(INSERT_PRODUCT))
|
||||
{
|
||||
@@ -478,7 +478,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
_procureNext.put(castleId, list);
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ? AND next_period = 1");
|
||||
PreparedStatement ips = con.prepareStatement(INSERT_CROP))
|
||||
{
|
||||
@@ -512,7 +512,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
|
||||
public final void updateCurrentProduction(int castleId, Collection<SeedProduction> items)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_production SET amount = ? WHERE castle_id = ? AND seed_id = ? AND next_period = 0"))
|
||||
{
|
||||
for (SeedProduction sp : items)
|
||||
@@ -532,7 +532,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
|
||||
public final void updateCurrentProcure(int castleId, Collection<CropProcure> items)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_procure SET amount = ? WHERE castle_id = ? AND crop_id = ? AND next_period = 0"))
|
||||
{
|
||||
for (CropProcure sp : items)
|
||||
@@ -605,7 +605,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
@Override
|
||||
public final boolean storeMe()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production");
|
||||
PreparedStatement is = con.prepareStatement(INSERT_PRODUCT);
|
||||
PreparedStatement dp = con.prepareStatement("DELETE FROM castle_manor_procure");
|
||||
@@ -703,7 +703,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
|
||||
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ?");
|
||||
PreparedStatement dc = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ?"))
|
||||
{
|
||||
|
Reference in New Issue
Block a user