use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class Case_Concurrent_50 method test_0.
public void test_0() throws Exception {
final DruidDataSource dataSource = new DruidDataSource();
dataSource.setInitialSize(initialSize);
dataSource.setMaxActive(maxActive);
dataSource.setMinIdle(minIdle);
dataSource.setMaxIdle(maxIdle);
dataSource.setPoolPreparedStatements(true);
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(jdbcUrl);
dataSource.setPoolPreparedStatements(true);
dataSource.setMaxWait(6000);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setValidationQuery(validationQuery);
dataSource.setTestOnBorrow(testOnBorrow);
dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
for (int i = 0; i < LOOP_COUNT; ++i) {
p0(dataSource, "druid");
}
System.out.println();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class Oracle_Case3 method test_0.
public void test_0() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setMaxActive(maxActive);
dataSource.setMaxIdle(maxIdle);
dataSource.setMaxWait(maxWait);
dataSource.setPoolPreparedStatements(true);
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(jdbcUrl);
dataSource.setPoolPreparedStatements(true);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setValidationQuery(validationQuery);
dataSource.setTestOnBorrow(testOnBorrow);
for (int i = 0; i < loopCount; ++i) {
p0(dataSource, "druid", threadCount);
}
System.out.println();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class TestRollBack method init.
// jdbcUrl = "jdbc:oracle:thin:@a.b.c.d:1521:ocnauto";
// user = "alibaba";
// password = "ccbuauto";
@BeforeClass
public static void init() throws PropertyVetoException, SQLException {
c3p0 = new ComboPooledDataSource();
// c3p0.setDriverClass("oracle.jdbc.driver.OracleDriver");
c3p0.setDriverClass(driver);
c3p0.setJdbcUrl(url);
c3p0.setUser(user);
c3p0.setPassword(password);
druid = new DruidDataSource();
druid.setUrl(url);
druid.setUsername(user);
druid.setPassword(password);
druid.setFilters("stat,trace,encoding");
druid.setDefaultAutoCommit(false);
dao_c3p0 = new NutDao(c3p0);
dao_druid = new NutDao(druid);
if (!dao_c3p0.exists("msg")) {
// 字段长度5
dao_c3p0.execute(Sqls.create("create table msg(message varchar(5))"));
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class TestTraceFilter method test_loop.
public void test_loop() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setFilters("stat,trace");
dataSource.setUrl("jdbc:mock:");
JMXUtils.register("com.alibaba.dragoon:type=JdbcTraceManager", JdbcTraceManager.getInstance());
for (int i = 0; i < 1000; ++i) {
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1");
rs.next();
rs.close();
stmt.close();
conn.close();
Thread.sleep(1000);
}
dataSource.close();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class TestOracle method test_o.
public void test_o() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(jdbcUrl);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setPoolPreparedStatements(true);
dataSource.setMaxOpenPreparedStatements(50);
dataSource.setUseOracleImplicitCache(true);
for (int i = 1; i <= 1; ++i) {
Connection conn = dataSource.getConnection();
// (i % 50) + 1;
int rowNum = i + 1;
String sql = SQL + " AND ROWNUM <= " + rowNum;
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setInt(1, 61);
ResultSet rs = stmt.executeQuery();
int rowCount = 0;
while (rs.next()) {
rowCount++;
}
Assert.assertEquals(true, rowCount > 0);
// Assert.isTrue(!rs.isClosed());
rs.close();
// Assert.isTrue(!stmt.isClosed());
stmt.close();
conn.close();
}
dataSource.close();
}
Aggregations