mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] Support hikariMaxLifetime
This commit is contained in:
parent
d4f63a4e19
commit
bd83e8a4c5
2 changed files with 5 additions and 0 deletions
|
@ -33,6 +33,7 @@ public final class MySQLSourceConfig implements AutoCloseable, SQLSourceConfig {
|
|||
private String password;
|
||||
private String database;
|
||||
private String timezone;
|
||||
private long hikariMaxLifetime = 30*60*1000; // 30 minutes
|
||||
private boolean useHikari;
|
||||
|
||||
// Cache
|
||||
|
@ -110,6 +111,7 @@ public synchronized Connection getConnection() throws SQLException {
|
|||
hikariConfig.setConnectionTimeout(1000);
|
||||
hikariConfig.setAutoCommit(true);
|
||||
hikariConfig.setLeakDetectionThreshold(2000);
|
||||
hikariConfig.setMaxLifetime(hikariMaxLifetime);
|
||||
// Set HikariCP pool
|
||||
// Replace source with hds
|
||||
source = new HikariDataSource(hikariConfig);
|
||||
|
|
|
@ -27,6 +27,8 @@ public final class PostgreSQLSourceConfig implements AutoCloseable, SQLSourceCon
|
|||
private String password;
|
||||
private String database;
|
||||
|
||||
private long hikariMaxLifetime = 30*60*1000; // 30 minutes
|
||||
|
||||
// Cache
|
||||
private transient DataSource source;
|
||||
private transient boolean hikari;
|
||||
|
@ -66,6 +68,7 @@ public synchronized Connection getConnection() throws SQLException {
|
|||
hikariSource.setMinimumIdle(0);
|
||||
hikariSource.setMaximumPoolSize(MAX_POOL_SIZE);
|
||||
hikariSource.setIdleTimeout(TIMEOUT * 1000L);
|
||||
hikariSource.setMaxLifetime(hikariMaxLifetime);
|
||||
|
||||
// Replace source with hds
|
||||
source = hikariSource;
|
||||
|
|
Loading…
Reference in a new issue