Search in sources :

Example 91 with BasicDataSource

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

the class H2Database method upgrade.

public void upgrade() throws SQLException {
    BasicDataSource source = createDataSource(Boolean.FALSE);
    if (systemEnvironment.inDbDebugMode()) {
        LOG.info("In debug mode - not upgrading database");
    // don't upgrade
    } else {
        Migration migrateSchema = new DbDeployMigration(source, systemEnvironment);
        migrateSchema.migrate();
    }
    shutdown();
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 92 with BasicDataSource

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

the class BackupServiceH2IntegrationTest method constructTestDataSource.

private BasicDataSource constructTestDataSource(File file) {
    BasicDataSource source = new BasicDataSource();
    source.setDriverClassName("org.h2.Driver");
    source.setUrl("jdbc:h2:" + file.getAbsolutePath() + "/cruise;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
    source.setUsername("sa");
    source.setPassword("");
    source.setMaxActive(32);
    source.setMaxIdle(32);
    return source;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 93 with BasicDataSource

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

the class BackupServiceH2IntegrationTest method shouldPerformDbBackupProperly.

@Test
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void shouldPerformDbBackupProperly() throws SQLException, IOException {
    Pipeline expectedPipeline = saveAPipeline();
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    backupService.startBackup(admin, result);
    assertThat(result.isSuccessful(), is(true));
    assertThat(result.message(localizer), is("Backup completed successfully."));
    String location = temporaryFolder.newFolder().getAbsolutePath();
    Restore.execute(dbZip(), location, "cruise", false);
    BasicDataSource source = constructTestDataSource(new File(location));
    ResultSet resultSet = source.getConnection().prepareStatement("select * from pipelines where id = " + expectedPipeline.getId()).executeQuery();
    int size = 0;
    while (resultSet.next()) {
        assertThat(resultSet.getString("name"), is(expectedPipeline.getName()));
        size++;
    }
    assertThat(size, is(1));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ResultSet(java.sql.ResultSet) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) File(java.io.File) Pipeline(com.thoughtworks.go.domain.Pipeline) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 94 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project kylo by Teradata.

the class JiraSpringTestConfig method dataSource.

@Bean
public DataSource dataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setUrl("jdbc:mysql://localhost:3306/pipeline_db");
    dataSource.setUsername("root");
    dataSource.setDriverClassName("org.mariadb.jdbc.Driver");
    // dataSource.setPassword("password");
    return dataSource;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Bean(org.springframework.context.annotation.Bean)

Example 95 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project pentaho-kettle by pentaho.

the class ConnectionPoolUtil method addPoolableDataSource.

/**
 * This methods adds a new data source to cache
 *
 * @param log
 * @param databaseMeta
 * @param partitionId
 * @param initialSize
 * @param maximumSize
 * @throws KettleDatabaseException
 */
private static void addPoolableDataSource(LogChannelInterface log, DatabaseMeta databaseMeta, String partitionId, int initialSize, int maximumSize) throws KettleDatabaseException {
    if (log.isBasic()) {
        log.logBasic(BaseMessages.getString(PKG, "Database.CreatingConnectionPool", databaseMeta.getName()));
    }
    BasicDataSource ds = new BasicDataSource();
    configureDataSource(ds, databaseMeta, partitionId, initialSize, maximumSize);
    // check if datasource is valid
    testDataSource(ds);
    // register data source
    dataSources.put(getDataSourceName(databaseMeta, partitionId), ds);
    if (log.isBasic()) {
        log.logBasic(BaseMessages.getString(PKG, "Database.CreatedConnectionPool", databaseMeta.getName()));
    }
}
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