Java Code Examples for com.zaxxer.hikari.HikariConfig#setInitializationFailTimeout()

The following examples show how to use com.zaxxer.hikari.HikariConfig#setInitializationFailTimeout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MysqlConnection.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DataSource dataSource() {
  String className = Driver.class.getName();
  HikariConfig config = toConfig();
  config.setDriverClassName(className);
  // A value less than zero will not bypass any connection attempt and validation during startup,
  // and therefore the pool will start immediately
  config.setInitializationFailTimeout(-1);
  return new HikariDataSource(config);
}
 
Example 2
Source File: MysqlChannelTest.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static JdbcTemplate getJdbcTemplate() throws UnknownHostException {
  MysqlConnection connection = new MysqlConnection("192.168.1.204", 3306, System.getenv("MYSQL_USER"), System.getenv("MYSQL_PASS"));

  HikariConfig config = connection.toConfig();
  config.setDriverClassName(Driver.class.getName());
  config.setInitializationFailTimeout(-1);
  HikariDataSource hikariDataSource = new HikariDataSource(config);

  return new JdbcTemplate(hikariDataSource);
}