HikariCP: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
(Created page with "==References== * [http://zetcode.com/articles/hikaricp HikariCP connection pool] * [https://www.baeldung.com/spring-boot-hikari Configuring a Hikari Connection Pool] * [https:...")
 
No edit summary
Line 1: Line 1:
<source lang="java">
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);
}
</source>
==References==
==References==
* [http://zetcode.com/articles/hikaricp HikariCP connection pool]
* [http://zetcode.com/articles/hikaricp HikariCP connection pool]

Revision as of 19:51, 21 September 2019

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);
}

References