Search in sources :

Example 1 with PooledDSFactory

use of cn.hutool.db.ds.pooled.PooledDSFactory in project hutool by looly.

the class DsTest method hutoolPoolTest.

@Test
public void hutoolPoolTest() throws SQLException {
    DSFactory.setCurrentDSFactory(new PooledDSFactory());
    DataSource ds = DSFactory.get();
    SqlRunner runner = SqlRunner.create(ds);
    List<Entity> all = runner.findAll("user");
    Assert.assertTrue(CollUtil.isNotEmpty(all));
}
Also used : Entity(cn.hutool.db.Entity) SqlRunner(cn.hutool.db.SqlRunner) PooledDSFactory(cn.hutool.db.ds.pooled.PooledDSFactory) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 2 with PooledDSFactory

use of cn.hutool.db.ds.pooled.PooledDSFactory in project hutool by looly.

the class DsTest method hutoolPoolTest.

@Test
public void hutoolPoolTest() throws SQLException {
    DSFactory.setCurrentDSFactory(new PooledDSFactory());
    DataSource ds = DSFactory.get("test");
    Db db = Db.use(ds);
    List<Entity> all = db.findAll("user");
    Assert.assertTrue(CollUtil.isNotEmpty(all));
}
Also used : PooledDSFactory(cn.hutool.db.ds.pooled.PooledDSFactory) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

PooledDSFactory (cn.hutool.db.ds.pooled.PooledDSFactory)2 DataSource (javax.sql.DataSource)2 Test (org.junit.Test)2 Entity (cn.hutool.db.Entity)1 SqlRunner (cn.hutool.db.SqlRunner)1 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1