Search in sources :

Example 6 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project pinpoint by naver.

the class HikariCpIT method setup.

@BeforeClass
public static void setup() {
    final HikariConfig config = new HikariConfig();
    config.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource");
    config.addDataSourceProperty("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
    dataSource = new HikariDataSource(config);
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig) BeforeClass(org.junit.BeforeClass)

Example 7 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project spring-boot by spring-projects.

the class SimpleDataSourceExampleTests method validateConfiguration.

@Test
public void validateConfiguration() throws SQLException {
    assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(1);
    HikariDataSource dataSource = this.context.getBean(HikariDataSource.class);
    assertThat(dataSource.getConnection().getMetaData().getURL()).isEqualTo("jdbc:h2:mem:simple");
    assertThat(dataSource.getMaximumPoolSize()).isEqualTo(42);
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 8 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project spring-boot by spring-projects.

the class ConfigurableDataSourceExampleTests method validateConfiguration.

@Test
public void validateConfiguration() throws SQLException {
    assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(1);
    HikariDataSource dataSource = this.context.getBean(HikariDataSource.class);
    assertThat(dataSource.getConnection().getMetaData().getURL()).isEqualTo("jdbc:h2:mem:configurable");
    assertThat(dataSource.getMaximumPoolSize()).isEqualTo(42);
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 9 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project spring-cloud-connectors by spring-cloud.

the class HikariCpPooledDataSourceCreator method create.

@Override
public DataSource create(RelationalServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig, String driverClassName, String validationQuery) {
    if (hasClass(HIKARI_DATASOURCE)) {
        logger.info("Found HikariCP on the classpath. Using it for DataSource connection pooling.");
        HikariDataSource ds = new HikariDataSource();
        setBasicDataSourceProperties(ds, serviceInfo, serviceConnectorConfig, driverClassName, validationQuery);
        return ds;
    } else {
        return null;
    }
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource)

Example 10 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project spring-boot by spring-projects.

the class DataSourceAutoConfigurationTests method hikariValidatesConnectionByDefault.

@Test
public void hikariValidatesConnectionByDefault() throws Exception {
    HikariDataSource dataSource = autoConfigureDataSource(HikariDataSource.class, "org.apache.tomcat");
    assertThat(dataSource.getConnectionTestQuery()).isNull();
// Use Connection#isValid()
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) Test(org.junit.Test)

Aggregations

HikariDataSource (com.zaxxer.hikari.HikariDataSource)114 Test (org.junit.Test)78 HikariConfig (com.zaxxer.hikari.HikariConfig)75 TestElf.newHikariConfig (com.zaxxer.hikari.pool.TestElf.newHikariConfig)63 Connection (java.sql.Connection)63 TestElf.newHikariDataSource (com.zaxxer.hikari.pool.TestElf.newHikariDataSource)33 StubConnection (com.zaxxer.hikari.mocks.StubConnection)29 SQLException (java.sql.SQLException)27 TestElf.setConfigUnitTest (com.zaxxer.hikari.pool.TestElf.setConfigUnitTest)16 StubDataSource (com.zaxxer.hikari.mocks.StubDataSource)10 MetricRegistry (com.codahale.metrics.MetricRegistry)8 PreparedStatement (java.sql.PreparedStatement)6 Statement (java.sql.Statement)6 PoolInitializationException (com.zaxxer.hikari.pool.HikariPool.PoolInitializationException)5 SQLTransientConnectionException (java.sql.SQLTransientConnectionException)5 Properties (java.util.Properties)5 ResultSet (java.sql.ResultSet)4 HealthCheckRegistry (com.codahale.metrics.health.HealthCheckRegistry)3 ArrayList (java.util.ArrayList)3 ExecutorService (java.util.concurrent.ExecutorService)3