Search in sources :

Example 11 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project sharding-jdbc by dangdangdotcom.

the class RdbTransactionLogStorageOperationsTest method assertRdbTransactionLogStorageOperations.

@Test
public void assertRdbTransactionLogStorageOperations() throws SQLException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:db_transaction_storage");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    createTable(dataSource);
    TransactionLogStorage storage = new RdbTransactionLogStorage(dataSource);
    assertTransactionLogStorageOperations(storage);
}
Also used : RdbTransactionLogStorage(com.dangdang.ddframe.rdb.transaction.soft.storage.impl.RdbTransactionLogStorage) RdbTransactionLogStorage(com.dangdang.ddframe.rdb.transaction.soft.storage.impl.RdbTransactionLogStorage) TransactionLogStorage(com.dangdang.ddframe.rdb.transaction.soft.storage.TransactionLogStorage) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Test(org.junit.Test)

Example 12 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project sharding-jdbc by dangdangdotcom.

the class RdbTransactionLogStorageTest method setup.

@Before
public void setup() throws SQLException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:db_trans");
    dataSource.setUsername("sa");
    createTable(dataSource);
    storage = new RdbTransactionLogStorage(dataSource);
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Before(org.junit.Before)

Example 13 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project sharding-jdbc by dangdangdotcom.

the class Main method createTransactionLogDataSource.

private static DataSource createTransactionLogDataSource() {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
    result.setUrl("jdbc:mysql://localhost:3306/trans_log");
    result.setUsername("root");
    result.setPassword("");
    return result;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 14 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project sharding-jdbc by dangdangdotcom.

the class Main method createDataSource.

private static DataSource createDataSource(final String dataSourceName) {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
    result.setUrl(String.format("jdbc:mysql://localhost:3306/%s", dataSourceName));
    result.setUsername("root");
    result.setPassword("");
    return result;
}
Also used : BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 15 with BasicDataSource

use of org.apache.commons.dbcp.BasicDataSource in project druid by alibaba.

the class Case4 method test_dbcp.

public void test_dbcp() throws Exception {
    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setInitialSize(initialSize);
    dataSource.setMaxActive(maxActive);
    dataSource.setMinIdle(minPoolSize);
    dataSource.setMaxIdle(maxPoolSize);
    dataSource.setPoolPreparedStatements(true);
    dataSource.setDriverClassName(driverClass);
    dataSource.setUrl(jdbcUrl);
    dataSource.setPoolPreparedStatements(true);
    dataSource.setMaxOpenPreparedStatements(maxOpenPreparedStatements);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setTestOnBorrow(false);
    for (int i = 0; i < loopCount; ++i) {
        p0(dataSource, "dbcp", threadCount);
    }
    System.out.println();
}
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