this is enough.
This commit is contained in:
parent
3ede8f0dae
commit
56aca7f473
@ -1,26 +1,18 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import com.zaxxer.hikari.pool.PoolInitializationException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MySQL implements DataSource {
|
||||
|
||||
private String host;
|
||||
@ -108,19 +100,18 @@ public class MySQL implements DataSource {
|
||||
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
||||
config.setUsername(this.username);
|
||||
config.setPassword(this.password);
|
||||
if (Settings.isMySQLWebsite)
|
||||
{
|
||||
if (Settings.isMySQLWebsite) {
|
||||
config.addDataSourceProperty("cachePrepStmts", "false");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
}
|
||||
config.addDataSourceProperty("autoReconnect", false);
|
||||
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
|
||||
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavailable
|
||||
config.setMaxLifetime(180000); // 3 Min
|
||||
config.setIdleTimeout(60000); // 1 Min
|
||||
config.setMinimumIdle(2);
|
||||
config.setMaximumPoolSize(maxConnections);
|
||||
ds = new HikariDataSource(config);
|
||||
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
||||
@ -136,24 +127,7 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
|
||||
private synchronized Connection getConnection() throws SQLException {
|
||||
if (!ds.isClosed())
|
||||
{
|
||||
Connection con;
|
||||
con = ds.getConnection();
|
||||
return con;
|
||||
}
|
||||
ConsoleLogger.showError("Can't open a database connection!");
|
||||
if (Settings.isStopEnabled)
|
||||
{
|
||||
ConsoleLogger.showError("Server will ShuttingDown for Security reason");
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
private synchronized void setupConnection() throws SQLException {
|
||||
|
||||
@ -10,7 +10,7 @@ DataSource:
|
||||
# Database Port
|
||||
mySQLPort: '3306'
|
||||
# MySql Max Connections
|
||||
mySQLMaxConections: 25
|
||||
mySQLMaxConections: 8
|
||||
# Username about Database Connection Infos
|
||||
mySQLUsername: authme
|
||||
# Password about Database Connection Infos
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user