Search in sources :

Example 6 with SqlRunner

use of cn.hutool.db.SqlRunner 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 7 with SqlRunner

use of cn.hutool.db.SqlRunner in project hutool by looly.

the class DsTest method hikariDsTest.

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

Aggregations

Entity (cn.hutool.db.Entity)7 SqlRunner (cn.hutool.db.SqlRunner)7 DataSource (javax.sql.DataSource)7 Test (org.junit.Test)7 C3p0DSFactory (cn.hutool.db.ds.c3p0.C3p0DSFactory)1 DbcpDSFactory (cn.hutool.db.ds.dbcp.DbcpDSFactory)1 DruidDSFactory (cn.hutool.db.ds.druid.DruidDSFactory)1 HikariDSFactory (cn.hutool.db.ds.hikari.HikariDSFactory)1 PooledDSFactory (cn.hutool.db.ds.pooled.PooledDSFactory)1 TomcatDSFactory (cn.hutool.db.ds.tomcat.TomcatDSFactory)1