mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Update hikari version
This commit is contained in:
parent
7b712e7f90
commit
680ad3c145
@ -101,13 +101,6 @@
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- HikariCP - needed as source -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@ -50,7 +50,7 @@
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<version>2.6.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Jedis -->
|
||||
|
@ -33,7 +33,7 @@ public enum Dependency {
|
||||
POSTGRESQL_DRIVER("https://repo1.maven.org/maven2/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar", "9.4.1212", "org.postgresql.ds.PGSimpleDataSource"),
|
||||
H2_DRIVER("https://repo1.maven.org/maven2/com/h2database/h2/1.4.193/h2-1.4.193.jar", "1.4.193", "org.h2.Driver"),
|
||||
SQLITE_DRIVER("https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.15.1/sqlite-jdbc-3.15.1.jar", "3.15.1", "org.sqlite.JDBC"),
|
||||
HIKARI("https://repo1.maven.org/maven2/com/zaxxer/HikariCP/2.5.1/HikariCP-2.5.1.jar", "2.5.1", "com.zaxxer.hikari.HikariDataSource"),
|
||||
HIKARI("https://repo1.maven.org/maven2/com/zaxxer/HikariCP/2.6.1/HikariCP-2.6.1.jar", "2.6.1", "com.zaxxer.hikari.HikariConfig"),
|
||||
SLF4J_SIMPLE("https://repo1.maven.org/maven2/org/slf4j/slf4j-simple/1.7.9/slf4j-simple-1.7.9.jar", "1.7.9", "org.slf4j.impl.SimpleLoggerFactory"),
|
||||
SLF4J_API("https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.9/slf4j-api-1.7.9.jar", "1.7.9", "org.slf4j.helpers.BasicMarkerFactory"),
|
||||
MONGODB_DRIVER("https://repo1.maven.org/maven2/org/mongodb/mongo-java-driver/3.4.1/mongo-java-driver-3.4.1.jar", "3.4.1", "com.mongodb.Mongo"),
|
||||
|
@ -23,6 +23,7 @@
|
||||
package me.lucko.luckperms.common.storage.backing.sqlprovider;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@ -57,18 +58,25 @@ abstract class FlatfileProvider extends SQLProvider {
|
||||
public WrappedConnection getConnection() throws SQLException {
|
||||
lock.lock();
|
||||
try {
|
||||
if (connection == null || connection.isClosed()) {
|
||||
if (this.connection == null || this.connection.isClosed()) {
|
||||
try {
|
||||
Class.forName(getDriverClass());
|
||||
} catch (ClassNotFoundException ignored) {}
|
||||
|
||||
connection = new WrappedConnection(DriverManager.getConnection(getDriverId() + ":" + file.getAbsolutePath()), false);
|
||||
Connection connection = DriverManager.getConnection(getDriverId() + ":" + file.getAbsolutePath());
|
||||
if (connection != null) {
|
||||
this.connection = new WrappedConnection(connection, false);
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
return connection;
|
||||
if (this.connection == null) {
|
||||
throw new SQLException("Connection is null");
|
||||
}
|
||||
|
||||
return this.connection;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -62,21 +63,26 @@ public class MySQLProvider extends SQLProvider {
|
||||
config.addDataSourceProperty("databaseName", database);
|
||||
config.addDataSourceProperty("user", username);
|
||||
config.addDataSourceProperty("password", password);
|
||||
config.addDataSourceProperty("cachePrepStmts", true);
|
||||
config.addDataSourceProperty("prepStmtCacheSize", 250);
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
|
||||
config.addDataSourceProperty("useServerPrepStmts", true);
|
||||
config.addDataSourceProperty("cacheCallableStmts", true);
|
||||
config.addDataSourceProperty("alwaysSendSetIsolation", false);
|
||||
config.addDataSourceProperty("cacheServerConfiguration", true);
|
||||
config.addDataSourceProperty("elideSetAutoCommits", true);
|
||||
config.addDataSourceProperty("useLocalSessionState", true);
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
config.addDataSourceProperty("useServerPrepStmts", "true");
|
||||
config.addDataSourceProperty("cacheCallableStmts", "true");
|
||||
config.addDataSourceProperty("alwaysSendSetIsolation", "false");
|
||||
config.addDataSourceProperty("cacheServerConfiguration", "true");
|
||||
config.addDataSourceProperty("elideSetAutoCommits", "true");
|
||||
config.addDataSourceProperty("useLocalSessionState", "true");
|
||||
config.addDataSourceProperty("characterEncoding", "utf8");
|
||||
config.addDataSourceProperty("useUnicode", "true");
|
||||
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(10)); // 10000
|
||||
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(5)); // 5000
|
||||
config.setValidationTimeout(TimeUnit.SECONDS.toMillis(3)); // 3000
|
||||
config.setInitializationFailFast(true);
|
||||
|
||||
// We will wait for 15 seconds to get a connection from the pool.
|
||||
// Default is 30, but it shouldn't be taking that long.
|
||||
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(15)); // 15000
|
||||
|
||||
// If a connection is not returned within 10 seconds, it's probably safe to assume it's been leaked.
|
||||
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(10)); // 10000
|
||||
|
||||
// The drivers are really old in some of the older Spigot binaries, so Connection#isValid doesn't work.
|
||||
config.setConnectionTestQuery("/* LuckPerms ping */ SELECT 1");
|
||||
|
||||
hikari = new HikariDataSource(config);
|
||||
@ -91,6 +97,10 @@ public class MySQLProvider extends SQLProvider {
|
||||
|
||||
@Override
|
||||
public WrappedConnection getConnection() throws SQLException {
|
||||
return new WrappedConnection(hikari.getConnection(), true);
|
||||
Connection connection = hikari.getConnection();
|
||||
if (connection == null) {
|
||||
throw new SQLException("Connection is null");
|
||||
}
|
||||
return new WrappedConnection(connection, true);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import me.lucko.luckperms.common.storage.DatastoreConfiguration;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -62,10 +63,15 @@ public class PostgreSQLProvider extends SQLProvider {
|
||||
config.addDataSourceProperty("databaseName", database);
|
||||
config.addDataSourceProperty("user", username);
|
||||
config.addDataSourceProperty("password", password);
|
||||
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(10)); // 10000
|
||||
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(5)); // 5000
|
||||
config.setValidationTimeout(TimeUnit.SECONDS.toMillis(3)); // 3000
|
||||
config.setInitializationFailFast(true);
|
||||
|
||||
// We will wait for 15 seconds to get a connection from the pool.
|
||||
// Default is 30, but it shouldn't be taking that long.
|
||||
config.setConnectionTimeout(TimeUnit.SECONDS.toMillis(15)); // 15000
|
||||
|
||||
// If a connection is not returned within 10 seconds, it's probably safe to assume it's been leaked.
|
||||
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(10)); // 10000
|
||||
|
||||
// Just in-case the driver isn't JDBC4+
|
||||
config.setConnectionTestQuery("/* LuckPerms ping */ SELECT 1");
|
||||
|
||||
hikari = new HikariDataSource(config);
|
||||
@ -80,6 +86,10 @@ public class PostgreSQLProvider extends SQLProvider {
|
||||
|
||||
@Override
|
||||
public WrappedConnection getConnection() throws SQLException {
|
||||
return new WrappedConnection(hikari.getConnection(), true);
|
||||
Connection connection = hikari.getConnection();
|
||||
if (connection == null) {
|
||||
throw new SQLException("Connection is null");
|
||||
}
|
||||
return new WrappedConnection(connection, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user