HikariCP: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 18: | Line 18: | ||
HikariDataSource ds = new HikariDataSource(config); | HikariDataSource ds = new HikariDataSource(config); | ||
} | } | ||
</source> | |||
<source lang="yaml"> | |||
spring: | |||
datasource: | |||
type: com.zaxxer.hikari.HikariDataSource | |||
url: jdbc:postgresql://sql.chorke.org:5432/academia | |||
username: ${academia.datasource.username} | |||
password: ${academia.datasource.password} | |||
driver-class-name: org.postgresql.Driver | |||
hikari: | |||
pool-name: java:jboss/datasources/CKiPostgresql_init_devDS | |||
connection-test-query: SELECT 1 | |||
auto-commit: false | |||
</source> | </source> | ||
Revision as of 23:29, 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);
}
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://sql.chorke.org:5432/academia
username: ${academia.datasource.username}
password: ${academia.datasource.password}
driver-class-name: org.postgresql.Driver
hikari:
pool-name: java:jboss/datasources/CKiPostgresql_init_devDS
connection-test-query: SELECT 1
auto-commit: false