Search in sources :

Example 1 with C3p0DSFactory

use of cn.hutool.db.ds.c3p0.C3p0DSFactory in project hutool by looly.

the class DsTest method c3p0DsTest.

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

Example 2 with C3p0DSFactory

use of cn.hutool.db.ds.c3p0.C3p0DSFactory in project hutool by looly.

the class DsTest method c3p0DsUserAndPassTest.

@Test
public void c3p0DsUserAndPassTest() {
    // https://gitee.com/dromara/hutool/issues/I4T7XZ
    DSFactory.setCurrentDSFactory(new C3p0DSFactory());
    ComboPooledDataSource ds = (ComboPooledDataSource) ((DataSourceWrapper) DSFactory.get("mysql")).getRaw();
    Assert.assertEquals("root", ds.getUser());
    Assert.assertEquals("123456", ds.getPassword());
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) C3p0DSFactory(cn.hutool.db.ds.c3p0.C3p0DSFactory) Test(org.junit.Test)

Example 3 with C3p0DSFactory

use of cn.hutool.db.ds.c3p0.C3p0DSFactory in project hutool by looly.

the class DsTest method c3p0DsTest.

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

Aggregations

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