Search in sources :

Example 1 with SqlRunner

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

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

the class DsTest method defaultDsTest.

@Test
public void defaultDsTest() throws SQLException {
    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) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 3 with SqlRunner

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

the class DsTest method dbcpDsTest.

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

Example 4 with SqlRunner

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

the class DsTest method tomcatDsTest.

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

Example 5 with SqlRunner

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

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