mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Tweak Hikari pool options, reduce connection requirement on startup
This commit is contained in:
1 parent
201c77ec4b
commit
10b5c25684
2 files changed
+17
-2
No files matched your search
@@ -250,7 +250,7 @@ public class Settings {
|
|||||||
public int idle = 10;
|
public int idle = 10;
|
||||||
public long lifetime = 1800000;
|
public long lifetime = 1800000;
|
||||||
public long keepalive = 0;
|
public long keepalive = 0;
|
||||||
public long timeout = 5000;
|
public long timeout = 20000;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public ConnectionPoolOptions() {
|
public ConnectionPoolOptions() {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class MySqlDatabase extends Database {
|
|||||||
dataSource.setUsername(username);
|
dataSource.setUsername(username);
|
||||||
dataSource.setPassword(password);
|
dataSource.setPassword(password);
|
||||||
|
|
||||||
// Set various additional parameters
|
// Set connection pool options
|
||||||
dataSource.setMaximumPoolSize(poolOptions.size);
|
dataSource.setMaximumPoolSize(poolOptions.size);
|
||||||
dataSource.setMinimumIdle(poolOptions.idle);
|
dataSource.setMinimumIdle(poolOptions.idle);
|
||||||
dataSource.setMaxLifetime(poolOptions.lifetime);
|
dataSource.setMaxLifetime(poolOptions.lifetime);
|
||||||
@@ -80,6 +80,21 @@ public class MySqlDatabase extends Database {
|
|||||||
dataSource.setConnectionTimeout(poolOptions.timeout);
|
dataSource.setConnectionTimeout(poolOptions.timeout);
|
||||||
dataSource.setPoolName(DATA_POOL_NAME);
|
dataSource.setPoolName(DATA_POOL_NAME);
|
||||||
|
|
||||||
|
// Set additional connection pool properties
|
||||||
|
dataSource.setDataSourceProperties(new Properties() {{
|
||||||
|
put("cachePrepStmts", "true");
|
||||||
|
put("prepStmtCacheSize", "250");
|
||||||
|
put("prepStmtCacheSqlLimit", "2048");
|
||||||
|
put("useServerPrepStmts", "true");
|
||||||
|
put("useLocalSessionState", "true");
|
||||||
|
put("useLocalTransactionState", "true");
|
||||||
|
put("rewriteBatchedStatements", "true");
|
||||||
|
put("cacheResultSetMetadata", "true");
|
||||||
|
put("cacheServerConfiguration", "true");
|
||||||
|
put("elideSetAutoCommits", "true");
|
||||||
|
put("maintainTimeStats", "false");
|
||||||
|
}});
|
||||||
|
|
||||||
// Prepare database schema; make tables if they don't exist
|
// Prepare database schema; make tables if they don't exist
|
||||||
try (Connection connection = dataSource.getConnection()) {
|
try (Connection connection = dataSource.getConnection()) {
|
||||||
// Load database schema CREATE statements from schema file
|
// Load database schema CREATE statements from schema file
|
||||||
|
|||||||
Reference in new issue
Block a user