#Database selection on connection timeout HikariCP
1 messages · Page 1 of 1 (latest)
Here's the actual code for the connection pool setting:
public void load()
{
getConfig().setJdbcUrl( "jdbc:mysql://{host}:{port}".replace("{host}", host).replace("{port}", port));
getConfig().setUsername(username);
getConfig().setPassword(password);
getConfig().setPoolName("ZeCharacterPool");
getConfig().setLeakDetectionThreshold(10000);
getConfig().setMaximumPoolSize(10);
getConfig().setConnectionTimeout(30000);
getConfig().setConnectionTestQuery("SELECT 1;");
getConfig().addDataSourceProperty("useUnicode", "true");
getConfig().addDataSourceProperty("characterEncoding", "utf8");
getConfig().addDataSourceProperty("encoding", "UTF-8");
getConfig().addDataSourceProperty("rewriteBatchedStatements", "true");
getConfig().addDataSourceProperty("cachePrepStmts" , "true");
getConfig().addDataSourceProperty("prepStmtCacheSize" , "275");
getConfig().addDataSourceProperty("prepStmtCacheSqlLimit" , "2048");
setDs(new HikariDataSource(getConfig()));
for(String statement : SQLCreateTable.split("\n"))
{
try(Connection conn = getSQLConnection(); Statement s = conn.createStatement())
{
s.executeUpdate(statement);
}
catch(SQLException e)
{
e.printStackTrace();
}
}
getConfig().setJdbcUrl( "jdbc:mysql://{host}:{port}/{database}".replace("{host}", host).replace("{port}", port).replace("{database}", database));
setDs(new HikariDataSource(getConfig()));
}