HikariCP: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 21: | Line 21: | ||
==References== | ==References== | ||
* [https://github.com/brettwooldridge/HikariCP HikariCP] | |||
* [https://www.baeldung.com/hikaricp Introduction to HikariCP] | |||
* [http://zetcode.com/articles/hikaricp HikariCP connection pool] | * [http://zetcode.com/articles/hikaricp HikariCP connection pool] | ||
* [https://stackoverflow.com/questions/26490967 How do I configure HikariCP] | |||
* [https://www.baeldung.com/spring-boot-hikari Configuring a Hikari Connection Pool] | * [https://www.baeldung.com/spring-boot-hikari Configuring a Hikari Connection Pool] | ||
* [https://www.programcreek.com/java-api-examples/?api=com.zaxxer.hikari.HikariDataSource Java Code Examples for HikariDataSource] | * [https://www.programcreek.com/java-api-examples/?api=com.zaxxer.hikari.HikariDataSource Java Code Examples for HikariDataSource] | ||
* [https://stackoverflow.com/questions/23630123 How to configure datasource with HikariCP] | * [https://stackoverflow.com/questions/23630123 How to configure datasource with HikariCP] |
Revision as of 23:09, 10 March 2020
public Database() {
try {
Class.forName("org.mariadb.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
HikariConfig config = new HikariConfig();
config.setJdbcUrl(App.getConfig().getString("database.url"));
config.setUsername(App.getConfig().getString("database.user"));
config.setPassword(App.getConfig().getString("database.pass"));
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("allowMultiQueries", "true");
config.setMaximumPoolSize(200); // this is plenty, the websocket uses 32
HikariDataSource ds = new HikariDataSource(config);
}