mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Set up leakDetection & Pool name incrementation for MySQL
This commit is contained in:
parent
00bd119481
commit
1f624078d9
@ -4,6 +4,7 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
@ -19,7 +20,9 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class MySQLDB extends SQLDB {
|
||||
|
||||
protected DataSource dataSource;
|
||||
private static int increment = 1;
|
||||
|
||||
protected volatile DataSource dataSource;
|
||||
|
||||
public MySQLDB(Supplier<Locale> locale) {
|
||||
super(locale);
|
||||
@ -48,12 +51,14 @@ public class MySQLDB extends SQLDB {
|
||||
config.setUsername(username);
|
||||
config.setPassword(password);
|
||||
|
||||
config.setPoolName("Plan Connection Pool");
|
||||
config.setPoolName("Plan Connection Pool-" + increment);
|
||||
config.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
increment++;
|
||||
|
||||
config.setAutoCommit(true);
|
||||
config.setReadOnly(false);
|
||||
config.setMaximumPoolSize(8);
|
||||
config.setLeakDetectionThreshold(TimeAmount.MINUTE.ms() * 10L);
|
||||
|
||||
this.dataSource = new HikariDataSource(config);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user