|
|
|
@@ -1,24 +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 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;
|
|
|
|
@@ -43,6 +37,7 @@ public class MySQL implements DataSource {
|
|
|
|
|
private List<String> columnOthers;
|
|
|
|
|
private HikariDataSource ds;
|
|
|
|
|
private String columnRealName;
|
|
|
|
|
private Connection connection;
|
|
|
|
|
|
|
|
|
|
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
|
|
|
|
this.host = Settings.getMySQLHost;
|
|
|
|
@@ -154,16 +149,11 @@ public class MySQL implements DataSource {
|
|
|
|
|
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private synchronized Connection getConnection() {
|
|
|
|
|
Connection con = null;
|
|
|
|
|
while(con == null){
|
|
|
|
|
try {
|
|
|
|
|
con = ds.getConnection();
|
|
|
|
|
} catch (SQLException ce) {
|
|
|
|
|
return null;
|
|
|
|
|
private synchronized Connection getConnection() throws SQLException {
|
|
|
|
|
if (connection == null || connection.isClosed()) {
|
|
|
|
|
connection = ds.getConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return con;
|
|
|
|
|
return connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private synchronized void setupConnection() throws SQLException {
|
|
|
|
@@ -268,7 +258,8 @@ public class MySQL implements DataSource {
|
|
|
|
|
if (!columnSalt.isEmpty()) {
|
|
|
|
|
if (!columnGroup.isEmpty())
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
else pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
else
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
} else {
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName).toLowerCase(), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
}
|
|
|
|
@@ -1047,7 +1038,8 @@ public class MySQL implements DataSource {
|
|
|
|
|
if (!columnSalt.isEmpty()) {
|
|
|
|
|
if (!columnGroup.isEmpty())
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
else
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
} else {
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
}
|
|
|
|
@@ -1098,7 +1090,8 @@ public class MySQL implements DataSource {
|
|
|
|
|
if (!columnSalt.isEmpty()) {
|
|
|
|
|
if (!columnGroup.isEmpty())
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
else
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
} else {
|
|
|
|
|
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
|
|
|
|
|
}
|
|
|
|
|