Search in sources :

Example 71 with BasicDataSource

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

the class OcDbTestCase method getDataSource.

@Override
public DataSource getDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setAccessToUnderlyingConnectionAllowed(true);
    ds.setDriverClassName(dbDriverClassName);
    ds.setUsername(dbUserName);
    ds.setPassword(dbPassword);
    ds.setUrl(dbUrl);
    return ds;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 72 with BasicDataSource

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

the class HibernateOcDbTestCase method getDataSource.

@Override
public DataSource getDataSource() {
    ds = new BasicDataSource();
    ds.setAccessToUnderlyingConnectionAllowed(true);
    ds.setDriverClassName(dbDriverClassName);
    ds.setUsername(dbUserName);
    ds.setPassword(dbPassword);
    ds.setUrl(dbUrl);
    return ds;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 73 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project elastic-job by dangdangdotcom.

the class BootstrapEnvironment method getJobEventRdbConfiguration.

/**
     * 获取作业数据库事件配置.
     *
     * @return 作业数据库事件配置
     */
public Optional<JobEventRdbConfiguration> getJobEventRdbConfiguration() {
    String driver = getValue(EnvironmentArgument.EVENT_TRACE_RDB_DRIVER);
    String url = getValue(EnvironmentArgument.EVENT_TRACE_RDB_URL);
    String username = getValue(EnvironmentArgument.EVENT_TRACE_RDB_USERNAME);
    String password = getValue(EnvironmentArgument.EVENT_TRACE_RDB_PASSWORD);
    if (!Strings.isNullOrEmpty(driver) && !Strings.isNullOrEmpty(url) && !Strings.isNullOrEmpty(username)) {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(driver);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return Optional.of(new JobEventRdbConfiguration(dataSource));
    }
    return Optional.absent();
}
Also used : JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 74 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project elastic-job by dangdangdotcom.

the class TaskExecutor method registered.

@Override
public void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo) {
    if (!executorInfo.getData().isEmpty()) {
        Map<String, String> data = SerializationUtils.deserialize(executorInfo.getData().toByteArray());
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(data.get("event_trace_rdb_driver"));
        dataSource.setUrl(data.get("event_trace_rdb_url"));
        dataSource.setPassword(data.get("event_trace_rdb_password"));
        dataSource.setUsername(data.get("event_trace_rdb_username"));
        jobEventBus = new JobEventBus(new JobEventRdbConfiguration(dataSource));
    }
}
Also used : JobEventBus(com.dangdang.ddframe.job.event.JobEventBus) JobEventRdbConfiguration(com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 75 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project elastic-job by dangdangdotcom.

the class JobEventRdbConfigurationTest method assertGetDataSource.

@Test
public void assertGetDataSource() throws JobEventListenerConfigurationException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:job_event_storage");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    assertThat((BasicDataSource) (new JobEventRdbConfiguration(dataSource).getDataSource()), is(dataSource));
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Test(org.junit.Test)

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