Merge remote-tracking branch 'remotes/origin/sql_pooling'
This commit is contained in:
commit
bf87cfd0cd
@ -1,5 +1,6 @@
|
||||
package mineplex.core.account.repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
@ -19,6 +20,7 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.DatabaseRunnable;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
@ -43,34 +45,9 @@ public class AccountRepository extends RepositoryBase
|
||||
|
||||
public AccountRepository(JavaPlugin plugin, String webAddress)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
|
||||
_webAddress = webAddress;
|
||||
|
||||
Statement statement = null;
|
||||
|
||||
try
|
||||
{
|
||||
statement = getConnection().createStatement();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (statement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,13 +58,11 @@ public class AccountRepository extends RepositoryBase
|
||||
|
||||
public void login(NautHashMap<String, ILoginProcessor> loginProcessors, String uuid, String name)
|
||||
{
|
||||
Statement statement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
try (
|
||||
Connection connection = getConnection();
|
||||
Statement statement = connection.createStatement()
|
||||
)
|
||||
{
|
||||
statement = getConnection().createStatement();
|
||||
|
||||
/*
|
||||
boolean statementStatus = statement.execute(
|
||||
"UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';"
|
||||
@ -152,32 +127,6 @@ public class AccountRepository extends RepositoryBase
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (statement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String GetClient(String name, UUID uuid, String ipAddress)
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.benefit;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
@ -16,7 +17,7 @@ public class BenefitManagerRepository extends RepositoryBase
|
||||
|
||||
public BenefitManagerRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,6 +16,7 @@ public final class DBPool
|
||||
{
|
||||
BasicDataSource source = new BasicDataSource();
|
||||
source.addConnectionProperty("autoReconnect", "true");
|
||||
source.addConnectionProperty("allowMultiQueries", "true");
|
||||
source.setDefaultAutoCommit(true);
|
||||
source.setEnableAutoCommitOnReturn(true);
|
||||
source.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
|
||||
@ -23,8 +24,8 @@ public final class DBPool
|
||||
source.setUrl(url);
|
||||
source.setUsername(username);
|
||||
source.setPassword(password);
|
||||
source.setMaxTotal(2);
|
||||
source.setMaxIdle(2);
|
||||
source.setMaxTotal(3);
|
||||
source.setMaxIdle(3);
|
||||
source.setTimeBetweenEvictionRunsMillis(180 * 1000);
|
||||
source.setSoftMinEvictableIdleTimeMillis(180 * 1000);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mineplex.core.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -22,58 +21,29 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class RepositoryBase implements Listener
|
||||
{
|
||||
protected static Object _connectionLock = new Object();
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
// Queue for failed processes
|
||||
private static Object _queueLock = new Object();
|
||||
|
||||
private NautHashMap<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
|
||||
|
||||
private String _connectionString;
|
||||
private String _userName;
|
||||
private String _password;
|
||||
|
||||
protected JavaPlugin Plugin;
|
||||
protected DataSource DataSource;
|
||||
|
||||
public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password)
|
||||
{
|
||||
Plugin = plugin;
|
||||
|
||||
_connectionString = connectionString;
|
||||
_userName = username;
|
||||
_password = password;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
initialize();
|
||||
update();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
private DataSource _dataSource; // Connection pool
|
||||
protected JavaPlugin Plugin; // Plugin responsible for this repository
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin - the {@link JavaPlugin} module responsible for this repository.
|
||||
* @param dataSource - the {@link DataSource} responsible for providing the connection pool to this repository.
|
||||
*/
|
||||
public RepositoryBase(JavaPlugin plugin, DataSource dataSource)
|
||||
{
|
||||
Plugin = plugin;
|
||||
DataSource = dataSource;
|
||||
_dataSource = dataSource;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
initialize();
|
||||
update();
|
||||
}
|
||||
initialize();
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
@ -84,34 +54,39 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
protected abstract void update();
|
||||
|
||||
/**
|
||||
* @return the {@link DataSource} used by the repository for connection pooling.
|
||||
*/
|
||||
protected DataSource getConnectionPool()
|
||||
{
|
||||
return _dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool!
|
||||
* @see Connection#close()
|
||||
* @return a newly fetched {@link Connection} from the connection pool, if a connection can be made, null otherwise.
|
||||
*/
|
||||
protected Connection getConnection()
|
||||
{
|
||||
return getConnection(false);
|
||||
}
|
||||
|
||||
protected Connection getConnection(boolean validate)
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || (validate && !_connection.isValid(2)))
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection = DataSource.getConnection();
|
||||
else
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return _dataSource.getConnection();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
// TODO: Log connection failures?
|
||||
return null;
|
||||
}
|
||||
|
||||
return _connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a query against the repository.
|
||||
* @param query - the concatenated query to execute in string form.
|
||||
* @param columns - the column data values used for insertion into the query.
|
||||
* @return the number of rows affected by this query in the repository.
|
||||
*/
|
||||
protected int executeUpdate(String query, Column<?>...columns)
|
||||
{
|
||||
return executeInsert(query, null, columns);
|
||||
@ -119,16 +94,14 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
protected int executeInsert(String query, ResultSetCallable callable, Column<?>...columns)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
int affectedRows = 0;
|
||||
|
||||
try
|
||||
// Automatic resource management for handling/closing objects.
|
||||
try (
|
||||
Connection connection = getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)
|
||||
)
|
||||
{
|
||||
getConnection(false);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
for (int i=0; i < columns.length; i++)
|
||||
{
|
||||
columns[i].setValue(preparedStatement, i+1);
|
||||
@ -137,49 +110,24 @@ public abstract class RepositoryBase implements Listener
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (callable != null)
|
||||
{
|
||||
callable.processResultSet(preparedStatement.getGeneratedKeys());
|
||||
}
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
getConnection(true);
|
||||
executeInsert(query, callable, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return affectedRows;
|
||||
}
|
||||
|
||||
protected void executeQuery(PreparedStatement statement, ResultSetCallable callable, Column<?>...columns)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i=0; i < columns.length; i++)
|
||||
@ -187,116 +135,39 @@ public abstract class RepositoryBase implements Listener
|
||||
columns[i].setValue(statement, i+1);
|
||||
}
|
||||
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
callable.processResultSet(resultSet);
|
||||
try (ResultSet resultSet = statement.executeQuery())
|
||||
{
|
||||
callable.processResultSet(resultSet);
|
||||
}
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
getConnection(true);
|
||||
executeQuery(statement, callable, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void executeQuery(String query, ResultSetCallable callable, Column<?>...columns)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
// Automatic resource management for handling/closing objects.
|
||||
try (
|
||||
Connection connection = getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(query)
|
||||
)
|
||||
{
|
||||
getConnection(false);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query);
|
||||
|
||||
executeQuery(preparedStatement, callable, columns);
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
getConnection(true);
|
||||
executeQuery(query, callable, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (DataSource != null)
|
||||
_connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int executeUpdate(PreparedStatement preparedStatement, Column<?>...columns)
|
||||
{
|
||||
int affectedRows = 0;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i=0; i < columns.length; i++)
|
||||
{
|
||||
columns[i].setValue(preparedStatement, i+1);
|
||||
}
|
||||
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
getConnection(true);
|
||||
executeUpdate(preparedStatement, columns);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return affectedRows;
|
||||
}
|
||||
|
||||
protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage)
|
||||
@ -341,24 +212,6 @@ public abstract class RepositoryBase implements Listener
|
||||
processFailedQueue();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void validateConnection(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_02 || DataSource != null)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
getConnection(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processFailedQueue()
|
||||
{
|
||||
synchronized (_queueLock)
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.DatabaseRunnable;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
@ -33,7 +34,7 @@ public class DonationRepository extends RepositoryBase
|
||||
|
||||
public DonationRepository(JavaPlugin plugin, String webAddress)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
|
||||
_webAddress = webAddress;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
@ -31,7 +32,7 @@ public class InventoryRepository extends RepositoryBase
|
||||
|
||||
public InventoryRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.leaderboard;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -35,7 +36,7 @@ public class StatEventsRepository extends RepositoryBase
|
||||
*/
|
||||
public StatEventsRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.preferences;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -14,7 +15,7 @@ import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class PreferencesRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
//private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;";
|
||||
|
||||
@ -36,12 +37,12 @@ public class PreferencesRepository extends RepositoryBase
|
||||
|
||||
public void saveUserPreferences(NautHashMap<String, UserPreferences> preferences)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
(
|
||||
Connection connection = getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
|
||||
)
|
||||
{
|
||||
preparedStatement = getConnection().prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
|
||||
|
||||
for (Entry<String, UserPreferences> entry : preferences.entrySet())
|
||||
{
|
||||
preparedStatement.setBoolean(1, entry.getValue().HubGames);
|
||||
@ -93,20 +94,6 @@ public class PreferencesRepository extends RepositoryBase
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException
|
||||
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
@ -40,7 +41,7 @@ This will be used to determine if staff are handling
|
||||
|
||||
public ReportRepository(JavaPlugin plugin, String connectionString)
|
||||
{
|
||||
super(plugin, connectionString, "root", "tAbechAk3wR7tuTh"); // TODO: Config file for host/pass?
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -22,8 +23,7 @@ public class SpawnRepository extends RepositoryBase
|
||||
|
||||
public SpawnRepository(JavaPlugin plugin, String serverName)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
_serverName = serverName;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -18,6 +19,7 @@ import org.jooq.DSLContext;
|
||||
import org.jooq.Insert;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Update;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
@ -31,7 +33,7 @@ public class StatsRepository extends RepositoryBase
|
||||
|
||||
public StatsRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,8 +81,7 @@ public class StatsRepository extends RepositoryBase
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
DSLContext context = DSL.using(getConnection(true));
|
||||
DSLContext context = DSL.using(getConnectionPool(), SQLDialect.MYSQL);
|
||||
|
||||
List<Update> updates = new ArrayList<>();
|
||||
List<Insert> inserts = new ArrayList<>();
|
||||
@ -133,7 +134,7 @@ public class StatsRepository extends RepositoryBase
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
context = DSL.using(getConnection());
|
||||
context = DSL.using(getConnectionPool(), SQLDialect.MYSQL);
|
||||
}
|
||||
|
||||
Result<Record2<String, Integer>> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats)
|
||||
|
@ -2,6 +2,7 @@ package mineplex.enjinTranslator;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -12,7 +13,7 @@ public class TempRepository extends RepositoryBase
|
||||
|
||||
public TempRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
public void addGemBooster(String name, int amount)
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnByte;
|
||||
@ -31,7 +32,7 @@ public class FieldRepository extends RepositoryBase
|
||||
|
||||
public FieldRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
public List<FieldBlockToken> getFieldBlocks(String server)
|
||||
|
@ -6,9 +6,11 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.MailRecord;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.impl.DSL;
|
||||
@ -19,7 +21,7 @@ public class MailRepository extends RepositoryBase
|
||||
|
||||
public MailRepository(JavaPlugin plugin, MailManager manager)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
|
||||
_manager = manager;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
@ -23,8 +24,7 @@ public class PasswordRepository extends RepositoryBase
|
||||
|
||||
public PasswordRepository(JavaPlugin plugin, String serverName)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
_serverName = serverName;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user