Example usage for org.apache.commons.dbutils QueryRunner QueryRunner

List of usage examples for org.apache.commons.dbutils QueryRunner QueryRunner

Introduction

In this page you can find the example usage for org.apache.commons.dbutils QueryRunner QueryRunner.

Prototype

public QueryRunner(DataSource ds) 

Source Link

Document

Constructor for QueryRunner that takes a DataSource to use.

Usage

From source file:azkaban.db.AzDBTestUtility.java

public static DatabaseOperator initQuartzDB() throws Exception {
    final AzkabanDataSource dataSource = new EmbeddedH2BasicDataSource();

    final String sqlScriptsDir = new File("../azkaban-web-server/src/test/resources/").getCanonicalPath();

    final DatabaseSetup setup = new DatabaseSetup(dataSource, sqlScriptsDir);
    setup.updateDatabase();/*from   w  w w.j  av a2 s  . c o m*/
    return new DatabaseOperator(new QueryRunner(dataSource));
}

From source file:cn.itcast.bbs.dao.AddressDao.java

public Address findAddressByIp(String ip) throws SQLException {
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "select *from address;";
    Address address = runner.query(sql, new BeanHandler(Address.class));
    return address;
}

From source file:cn.itcast.bbs.dao.UserDao.java

public User findUser(String username) throws SQLException {
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "select *from user where username = ?";
    User userFromDB = runner.query(sql, new BeanHandler(User.class), new Object[] { username });
    return userFromDB;
}

From source file:cn.itcast.bbs.dao.AdminDao.java

public Admin findAdminByType(String title) throws SQLException {
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "select *from admin where title = ?";
    Admin admin = runner.query(sql, new BeanHandler(Admin.class), title);
    return admin;
}

From source file:cn.itcast.bbs.dao.FlowDao.java

public Flow showFlow(Date date) throws SQLException {
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "select *from flow where historydate = ?";
    Flow flow = runner.query(sql, new BeanHandler(Flow.class), new java.sql.Date(date.getTime()));
    return flow;//w  w w.  ja v a2s . c o  m
}

From source file:be.bittich.dynaorm.ioc.BasicConfigurationBean.java

/**
 * configure a QueryRunner bean/*  www  . j  a v a2 s  .co  m*/
 */
private static void configureQueryRunner() {

    ConnectionDB bean = IOCFacadGet.getConnectionDB();
    QueryRunner run = new QueryRunner(bean.getDataSource());
    registerQueryRunner(run);

}

From source file:com.rhino.data.db.EquityDao.java

public List<String> getAllEquity() throws SQLException {
    String sql = "select distinct equity from EOD";
    QueryRunner run = new QueryRunner(DataSourceFactory.getDataSource());
    ResultSetHandler rsh = new ColumnListHandler();
    return (List<String>) run.query(sql, rsh);
}

From source file:cn.itcast.bbs.dao.TypeDao.java

public List<Type> findAllType() throws SQLException {
    List<Type> typeList = null;
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "select *from type;";
    typeList = runner.query(sql, new BeanListHandler(Type.class));
    return typeList;
}

From source file:com.fluke.database.dataservice.EquityDao.java

public List<String> getAllEquity() throws SQLException {
    String sql = "select distinct equity from EOD";
    QueryRunner run = new QueryRunner(DatabaseProperty.getDataSource());
    ResultSetHandler rsh = new ColumnListHandler();
    return (List<String>) run.query(sql, rsh);
}

From source file:cn.itcast.bbs.dao.ReplyDao.java

public List<Reply> showAllReplyByTopicId(int id) throws SQLException {
    List<Reply> replyList = null;
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "select *from reply where topic_id = ? order by time;";
    replyList = runner.query(sql, new BeanListHandler(Reply.class), id);
    return replyList;
}