Search in sources :

Example 46 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project pinpoint by naver.

the class DataSourceConstructorInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (!InterceptorUtils.isSuccess(throwable)) {
        return;
    }
    final BasicDataSource basicDataSource = getBasicDatasource(target);
    if (basicDataSource instanceof DataSourceMonitorAccessor) {
        DbcpDataSourceMonitor dataSourceMonitor = new DbcpDataSourceMonitor(basicDataSource);
        dataSourceMonitorRegistry.register(dataSourceMonitor);
        ((DataSourceMonitorAccessor) basicDataSource)._$PINPOINT$_setDataSourceMonitor(dataSourceMonitor);
    }
}
Also used : DbcpDataSourceMonitor(com.navercorp.pinpoint.plugin.commons.dbcp.DbcpDataSourceMonitor) DataSourceMonitorAccessor(com.navercorp.pinpoint.plugin.commons.dbcp.DataSourceMonitorAccessor) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 47 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project jOOQ by jOOQ.

the class Example_4_1_ConnectionProvider method run.

@Test
public void run() {
    Connection connection = connection();
    Tools.title("Using jOOQ with a standalone connection");
    System.out.println(DSL.using(connection).select().from(AUTHOR).fetch());
    Tools.title("Using jOOQ with a DBCP connection pool");
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(Tools.driver());
    ds.setUrl(Tools.url());
    ds.setUsername(Tools.username());
    ds.setPassword(Tools.password());
    System.out.println(DSL.using(ds, SQLDialect.H2).select().from(AUTHOR).fetch());
}
Also used : Connection(java.sql.Connection) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Test(org.junit.Test)

Example 48 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project jackrabbit by apache.

the class ConnectionFactoryTest method testGuessValidationQuery_MYSQL.

public void testGuessValidationQuery_MYSQL() throws Exception {
    DataSource ds1 = connectionFactory.getDataSource(DRIVER, MYSQL_URL, "user", "password");
    assertEquals("select 1", ((BasicDataSource) ds1).getValidationQuery());
}
Also used : DataSource(javax.sql.DataSource) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 49 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project jackrabbit by apache.

the class ConnectionFactoryTest method testGetDataSource_defaults_Derby.

public void testGetDataSource_defaults_Derby() throws Exception {
    DataSource ds1 = connectionFactory.getDataSource(DRIVER, DERBY_URL, "user", "password");
    assertTrue(ds1 instanceof BasicDataSource);
    BasicDataSource ds = (BasicDataSource) ds1;
    assertPoolDefaults(ds, "values(1)", -1);
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource) DataSource(javax.sql.DataSource) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 50 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project voldemort by voldemort.

the class MysqlStorageEngineTest method getDataSource.

private DataSource getDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl("jdbc:mysql://localhost:3306/test");
    ds.setUsername("root");
    ds.setPassword("");
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    return ds;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Aggregations

BasicDataSource (org.apache.commons.dbcp.BasicDataSource)141 Connection (java.sql.Connection)25 Test (org.junit.Test)13 SQLException (java.sql.SQLException)12 Properties (java.util.Properties)12 DataSource (javax.sql.DataSource)10 Platform (org.apache.ddlutils.Platform)8 Database (org.apache.ddlutils.model.Database)8 DdlGenerator (siena.jdbc.ddl.DdlGenerator)8 Statement (java.sql.Statement)7 Bean (org.springframework.context.annotation.Bean)6 ResultSet (java.sql.ResultSet)5 Before (org.junit.Before)5 JdbcPersistenceManager (siena.jdbc.JdbcPersistenceManager)5 Config (com.typesafe.config.Config)4 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Test (org.testng.annotations.Test)3 PostgresqlPersistenceManager (siena.jdbc.PostgresqlPersistenceManager)3