Java Code Examples for com.zaxxer.hikari.HikariDataSource#setLeakDetectionThreshold()
The following examples show how to use
com.zaxxer.hikari.HikariDataSource#setLeakDetectionThreshold() .
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: LocDataSourceAutoConfiguration.java From loc-framework with MIT License | 6 votes |
private HikariDataSource createHikariDataSource(JdbcProperties jdbcProperties) { HikariDataSource hikariDataSource = new HikariDataSource(); hikariDataSource.setJdbcUrl(jdbcProperties.getJdbcUrl()); hikariDataSource.setUsername(jdbcProperties.getUsername()); hikariDataSource.setPassword(jdbcProperties.getPassword()); JdbcPoolProperties jdbcPoolProperties = jdbcProperties.getJdbcPool(); hikariDataSource.setAutoCommit(jdbcPoolProperties.isAutoCommit()); hikariDataSource.setConnectionTimeout(jdbcPoolProperties.getConnectionTimeout()); hikariDataSource.setIdleTimeout(jdbcPoolProperties.getIdleTimeout()); hikariDataSource.setMaxLifetime(jdbcPoolProperties.getMaxLifetime()); hikariDataSource.setMaximumPoolSize(jdbcPoolProperties.getMaximumPoolSize()); hikariDataSource.setMinimumIdle(jdbcPoolProperties.getMinimumIdle()); hikariDataSource .setInitializationFailTimeout(jdbcPoolProperties.getInitializationFailTimeout()); hikariDataSource.setIsolateInternalQueries(jdbcPoolProperties.isIsolateInternalQueries()); hikariDataSource.setReadOnly(jdbcPoolProperties.isReadOnly()); hikariDataSource.setRegisterMbeans(jdbcPoolProperties.isRegisterMbeans()); Optional.ofNullable(jdbcPoolProperties.getDriverClassName()) .ifPresent(hikariDataSource::setDriverClassName); hikariDataSource.setValidationTimeout(jdbcPoolProperties.getValidationTimeout()); hikariDataSource.setLeakDetectionThreshold(jdbcPoolProperties.getLeakDetectionThreshold()); return hikariDataSource; }
Example 2
Source File: JobConfiguration.java From CogStack-Pipeline with Apache License 2.0 | 6 votes |
@Bean(destroyMethod = "close") @Primary @Qualifier("sourceDataSource") public DataSource sourceDataSource() { HikariDataSource mainDatasource = new HikariDataSource(); executeSessionScripts(mainDatasource,sourceDriver); mainDatasource.setDriverClassName(sourceDriver); mainDatasource.setJdbcUrl(sourceJdbcPath); mainDatasource.setUsername(sourceUserName); mainDatasource.setPassword(sourcePassword); mainDatasource.setIdleTimeout(sourceIdleTimeout); mainDatasource.setMaxLifetime(sourceMaxLifeTime); // show tables query does not work with post gres if (Arrays.asList(this.env.getActiveProfiles()).contains("docman") && ! Arrays.asList(this.env.getActiveProfiles()).contains("postgres")){ mainDatasource.setConnectionTestQuery("show tables"); } if (sourcePoolSize > 0){ mainDatasource.setMaximumPoolSize(sourcePoolSize); } // set the db connection leak detection time mainDatasource.setLeakDetectionThreshold(sourceLeakDetection); return mainDatasource; }
Example 3
Source File: HikariCPProvider.java From tastjava with MIT License | 4 votes |
@Override public boolean register() { if (IsRegistered) { return HAS_REGISTERED; } HikariDataSource ds = new HikariDataSource(); //basic config ds.setJdbcUrl(jdbcURL); ds.setDriverClassName(jdbcDriver); ds.setUsername(jdbcUsername); ds.setPassword(jdbcPassword); //custom config ds.setAutoCommit(autoCommit); ds.setConnectionTimeout(connectionTimeout); ds.setIdleTimeout(idleTimeout); ds.setMaxLifetime(maxLifetime); ds.setMaximumPoolSize(maximumPoolSize); ds.setValidationTimeout(validationTimeout); ds.setLeakDetectionThreshold(leakDetectionThreshold); if (!StrUtil.isBlank(poolName)) { ds.setPoolName(poolName); } if (!StrUtil.isBlank(catalog)) { ds.setCatalog(catalog); } if (!StrUtil.isBlank(connectionInitSql)) { ds.setConnectionInitSql(connectionInitSql); } if (!StrUtil.isBlank(transactionIsolation)) { ds.setTransactionIsolation(transactionIsolation); } if (jdbcURL.contains(":mysql:")) { ds.addDataSourceProperty("cachePrepStmts", "true"); ds.addDataSourceProperty("prepStmtCacheSize", "250"); ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); ds.addDataSourceProperty("useServerPrepStmts", "true"); } setDataSource(ds); setIsRegistered(HAS_REGISTERED); return HAS_REGISTERED; }