List of usage examples for org.apache.commons.dbutils QueryRunner QueryRunner
public QueryRunner(DataSource ds)
DataSource
to use. From source file:cn.itcast.bbs.dao.TopicDao.java
public List<Topic> showAllTopicByTypeId(int id) throws SQLException { List<Topic> topicList = null; QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource()); String sql = "select *from topic where type_id = ? order by time desc;"; topicList = runner.query(sql, new BeanListHandler(Topic.class), id); return topicList; }
From source file:com.example.data.StoreData.java
public Map<String, Object> findOrderById(long orderId) throws SQLException { QueryRunner run = new QueryRunner(H2DB.getDataSource()); return run/* www .ja v a 2s . c om*/ .query("select * from order where id=?", H2DB.mkResultSetHandler("id", "petId", "quantity", "shipDate", "status"), orderId) .stream().findFirst().orElse(null); }
From source file:com.example.data.UserData.java
public Map<String, Object> findUserByName(String username) throws SQLException { QueryRunner run = new QueryRunner(H2DB.getDataSource()); return run.query( "select id, user_name, first_name, last_name, email, phone, status from user where user_name=?", H2DB.mkResultSetHandler("id", "username", "firstName", "lastName", "email", "phone", "status"), username).stream().findFirst().orElse(null); }
From source file:cn.itcast.bbs.dao.UserDao.java
public void saveUser(User user) throws SQLException { QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource()); String sql = "insert into user(username,password,gender,email) values(?,?,?,?);"; runner.update(sql,//from w w w . jav a 2 s .c o m new Object[] { user.getUsername(), user.getPassword(), user.getGender(), user.getEmail() }); }
From source file:com.fluke.database.dataservice.IntraDayDaoTest.java
@Before @After/* w w w . java 2s. com*/ public void setup() throws SQLException { QueryRunner runner = new QueryRunner(DatabaseProperty.getDataSource()); runner.update("delete from intraday where equity='abcd'"); }
From source file:cn.itcast.bbs.dao.FlowDao.java
public void updateFlow(Flow flow) throws SQLException { QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource()); String sql = "update flow set num = ?,historydate = ? where id = ? "; System.out.println(flow.getNum() + ":" + new java.sql.Date(flow.getHistorydate().getTime())); runner.update(sql, new Object[] { flow.getNum(), new java.sql.Date(flow.getHistorydate().getTime()), 1 }); }
From source file:cn.itcast.bbs.dao.TypeDao.java
public void updateTypeClick(int id) throws SQLException { QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource()); String sql = "update type set click = click +1 where id = ?;"; runner.update(sql, id);// www .j a v a2 s. co m }
From source file:com.example.data.PetData.java
public Map<String, Object> getPetById(long petId) throws SQLException { QueryRunner run = new QueryRunner(H2DB.getDataSource()); return run//from www . j a va 2 s . co m .query("select * from pet where id=?", H2DB.mkResultSetHandler("id", "name", "categoryId", "photoUrls", "tags", "status"), petId) .stream().map(m -> { m.put("photoUrls", H2DB.strToList((String) m.get("photoUrls"))); m.put("tags", H2DB.strToList((String) m.get("tags"))); m.put("category", getCategory(run, (Long) m.get("categoryId"))); m.remove("categoryId"); return m; }).findFirst().orElse(null); }
From source file:com.rhino.data.db.EquityDao.java
public List<String> getAllEquity(String grade) throws SQLException { String sql = "select distinct equity from EOD where grade='" + grade + "'"; QueryRunner run = new QueryRunner(DataSourceFactory.getDataSource()); ResultSetHandler rsh = new ColumnListHandler(); return (List<String>) run.query(sql, rsh); }
From source file:com.fluke.database.dataservice.EquityDao.java
public List<String> getAllEquity(String grade) 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); }