Refactored DatabaseFactory.
This commit is contained in:
@@ -33,7 +33,7 @@ import java.util.Map;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.loginserver.network.gameserverpackets.ServerStatus;
|
||||
import com.l2jmobius.util.IPSubnet;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
@@ -111,7 +111,7 @@ public final class GameServerTable implements IXmlReader
|
||||
*/
|
||||
private void loadRegisteredGameServers()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
Statement ps = con.createStatement();
|
||||
ResultSet rs = ps.executeQuery("SELECT * FROM gameservers"))
|
||||
{
|
||||
@@ -218,7 +218,7 @@ public final class GameServerTable implements IXmlReader
|
||||
public void registerServerOnDB(byte[] hexId, int id, String externalHost)
|
||||
{
|
||||
register(id, new GameServerInfo(id, hexId));
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO gameservers (hexid,server_id,host) values (?,?,?)"))
|
||||
{
|
||||
ps.setString(1, hexToString(hexId));
|
||||
|
@@ -31,7 +31,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.Server;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.mmocore.SelectorConfig;
|
||||
import com.l2jmobius.commons.mmocore.SelectorThread;
|
||||
import com.l2jmobius.loginserver.network.L2LoginClient;
|
||||
@@ -90,7 +90,7 @@ public final class L2LoginServer
|
||||
Config.load();
|
||||
|
||||
// Prepare Database
|
||||
ConnectionFactory.getInstance();
|
||||
DatabaseFactory.getInstance();
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@ import java.util.logging.Logger;
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jmobius.loginserver.model.data.AccountInfo;
|
||||
import com.l2jmobius.loginserver.network.L2LoginClient;
|
||||
@@ -216,7 +216,7 @@ public class LoginController
|
||||
final byte[] raw = password.getBytes(StandardCharsets.UTF_8);
|
||||
final String hashBase64 = Base64.getEncoder().encodeToString(md.digest(raw));
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(USER_INFO_SELECT))
|
||||
{
|
||||
ps.setString(1, Long.toString(System.currentTimeMillis()));
|
||||
@@ -251,7 +251,7 @@ public class LoginController
|
||||
return null;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(AUTOCREATE_ACCOUNTS_INSERT))
|
||||
{
|
||||
ps.setString(1, login);
|
||||
@@ -451,7 +451,7 @@ public class LoginController
|
||||
|
||||
if (loginOk && (client.getLastServer() != serverId))
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ACCOUNT_LAST_SERVER_UPDATE))
|
||||
{
|
||||
ps.setInt(1, serverId);
|
||||
@@ -470,7 +470,7 @@ public class LoginController
|
||||
|
||||
public void setAccountAccessLevel(String account, int banLevel)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ACCOUNT_ACCESS_LEVEL_UPDATE))
|
||||
{
|
||||
ps.setInt(1, banLevel);
|
||||
@@ -485,7 +485,7 @@ public class LoginController
|
||||
|
||||
public void setAccountLastTracert(String account, String pcIp, String hop1, String hop2, String hop3, String hop4)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ACCOUNT_IPS_UPDATE))
|
||||
{
|
||||
ps.setString(1, pcIp);
|
||||
@@ -545,7 +545,7 @@ public class LoginController
|
||||
{
|
||||
final List<InetAddress> ipWhiteList = new ArrayList<>();
|
||||
final List<InetAddress> ipBlackList = new ArrayList<>();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ACCOUNT_IPAUTH_SELECT))
|
||||
{
|
||||
ps.setString(1, info.getLogin());
|
||||
@@ -591,7 +591,7 @@ public class LoginController
|
||||
|
||||
client.setAccessLevel(info.getAccessLevel());
|
||||
client.setLastServer(info.getLastServer());
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ACCOUNT_INFO_UPDATE))
|
||||
{
|
||||
ps.setLong(1, System.currentTimeMillis());
|
||||
|
@@ -25,7 +25,7 @@ import java.util.Collection;
|
||||
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.loginserver.GameServerTable;
|
||||
import com.l2jmobius.loginserver.GameServerTable.GameServerInfo;
|
||||
import com.l2jmobius.loginserver.GameServerThread;
|
||||
@@ -80,7 +80,7 @@ public class ChangePassword extends BaseRecievePacket
|
||||
int passUpdated = 0;
|
||||
|
||||
// SQL connection
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT password FROM accounts WHERE login=?"))
|
||||
{
|
||||
ps.setString(1, accountName);
|
||||
@@ -99,7 +99,7 @@ public class ChangePassword extends BaseRecievePacket
|
||||
password = md.digest(password);
|
||||
|
||||
// SQL connection
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET password=? WHERE login=?"))
|
||||
{
|
||||
ps.setString(1, Base64.getEncoder().encodeToString(password));
|
||||
|
@@ -22,7 +22,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.loginserver.LoginController;
|
||||
import com.l2jmobius.util.network.BaseRecievePacket;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class RequestTempBan extends BaseRecievePacket
|
||||
|
||||
private void banUser()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO account_data VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value=?"))
|
||||
{
|
||||
ps.setString(1, _accountName);
|
||||
|
Reference in New Issue
Block a user