Search in sources :

Example 1 with DruidDSFactory

use of cn.hutool.db.ds.druid.DruidDSFactory in project hutool by looly.

the class DsTest method druidDsTest.

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

Example 2 with DruidDSFactory

use of cn.hutool.db.ds.druid.DruidDSFactory in project hutool by looly.

the class DsTest method druidDsTest.

@Test
public void druidDsTest() throws SQLException {
    DSFactory.setCurrentDSFactory(new DruidDSFactory());
    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) DruidDSFactory(cn.hutool.db.ds.druid.DruidDSFactory) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

DruidDSFactory (cn.hutool.db.ds.druid.DruidDSFactory)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