List of usage examples for org.apache.commons.dbutils.handlers ArrayListHandler ArrayListHandler
public ArrayListHandler()
BasicRowProcessor
for conversions. From source file:org.teiid.embedded.helper.utils.JDBCUtils.java
public static void query(Connection conn, String sql) throws SQLException { System.out.println("Query SQL: " + sql); QueryRunner runner = new QueryRunner(); ArrayListHandler handler = new ArrayListHandler(); List<Object[]> results = runner.query(conn, sql, handler); dumpResults(results);/*from w ww . java2 s . c o m*/ }
From source file:org.teiid.embedded.helper.utils.JDBCUtils.java
public static void insert(Connection conn, String sql) throws SQLException { System.out.println("Insert SQL: " + sql); QueryRunner runner = new QueryRunner(); ArrayListHandler handler = new ArrayListHandler(); List<Object[]> results = runner.insert(conn, sql, handler); dumpResults(results);/*from ww w . j a va 2s . c om*/ }
From source file:org.yukung.tasklet.dao.impl.MemoDaoImpl.java
@Override public List<Object[]> findMemoIdByActivityId(int activityId) { String sql = getSQLFromPropertyFile("findMemoIdByActivityId"); ResultSetHandler<List<Object[]>> rsh = new ArrayListHandler(); try {// w w w.j a v a2 s . c om return runner.query(sql, rsh, Integer.valueOf(activityId)); } catch (SQLException e) { throw new DataAccessException(e.getMessage(), e); } }
From source file:org.yukung.tasklet.dao.impl.TaskDaoImpl.java
@Override public List<Object[]> findTaskIdByActivityId(int activityId) { String sql = getSQLFromPropertyFile("findTaskIdByActivityId"); ResultSetHandler<List<Object[]>> rsh = new ArrayListHandler(); try {// w w w. j a va2 s . c o m return runner.query(sql, rsh, Integer.valueOf(activityId)); } catch (SQLException e) { throw new DataAccessException(e.getMessage(), e); } }
From source file:steamgameselector.SteamData.java
public ArrayList<String> getTags() { ArrayList<String> tags = new ArrayList<String>(); try {// ww w . ja va 2 s.co m List<Object[]> objs = queryRunner.query("SELECT tag FROM Tag", new ArrayListHandler()); if (objs.size() > 0) { for (Object[] item : objs) { if (item.length > 0) tags.add((String) item[0]); } } return tags; } catch (SQLException ex) { Logger.getLogger(SteamData.class.getName()).log(Level.SEVERE, null, ex); } return tags; }
From source file:steamgameselector.SteamData.java
public ArrayList<String> getTags(int gameid) { ArrayList<String> tags = new ArrayList<>(); try {/*from w w w .j a va2 s . c o m*/ List<Object[]> objs = queryRunner.query( "SELECT T.tag FROM Tag T, GameTag G WHERE G.tagid=T.tagid AND G.gameid=?", new ArrayListHandler(), gameid); if (objs.size() > 0) { for (Object[] item : objs) { if (item.length > 0) tags.add((String) item[0]); } } return tags; } catch (SQLException ex) { Logger.getLogger(SteamData.class.getName()).log(Level.SEVERE, null, ex); } return tags; }
From source file:steamgameselector.SteamData.java
public ArrayList<Account> getAccounts() { ArrayList<Account> accounts = new ArrayList<Account>(); try {// w ww . j av a 2 s . c o m List<Object[]> objs = queryRunner.query("SELECT steamid FROM Account", new ArrayListHandler()); if (objs.size() > 0) { for (Object[] item : objs) { if (item.length > 0) accounts.add(getAccount((String) item[0])); } } return accounts; } catch (SQLException ex) { Logger.getLogger(SteamData.class.getName()).log(Level.SEVERE, null, ex); } return accounts; }
From source file:steamgameselector.SteamData.java
public Set<Game> getGames(int accountid) { Set<Game> games = new HashSet(); try {//from www . j a v a 2 s . co m List<Object[]> objs = queryRunner.query( "SELECT appid FROM AccountGame R, Game G WHERE R.gameid=G.gameid AND R.accountid=?", new ArrayListHandler(), accountid); if (objs.size() > 0) { for (Object[] item : objs) { if (item.length > 0) games.add(getSteamGame((Integer) item[0])); } } return games; } catch (SQLException ex) { Logger.getLogger(SteamData.class.getName()).log(Level.SEVERE, null, ex); } return games; }
From source file:steamgameselector.SteamData.java
public ArrayList<Game> getSharedGames() { ArrayList<Game> games = new ArrayList(); try {// w w w .j av a2 s . c om List<Object[]> objs = queryRunner.query("SELECT * FROM SharedGames", new ArrayListHandler()); if (objs.size() > 0) { for (Object[] item : objs) { if (item.length > 0) games.add(processGame(item)); } } return games; } catch (SQLException ex) { Logger.getLogger(SteamData.class.getName()).log(Level.SEVERE, null, ex); } return games; }
From source file:steamgameselector.SteamData.java
public ArrayList<Game> getFilteredGames(Set<Integer> andList, Set<Integer> orList, Set<Integer> notList) { if ((andList == null || andList.isEmpty()) && (orList == null || orList.isEmpty()) && (notList == null || notList.isEmpty())) return getSharedGames(); String query = "SELECT g.gameid, g.appid, g.title FROM SharedGames g,"; String queryTail = " WHERE"; if (andList != null && !andList.isEmpty()) { query += " (SELECT DISTINCT gameid FROM gametag WHERE (tagid IN (" + setToString(andList) + ")) GROUP BY gameid HAVING COUNT(gameid)=" + andList.size() + ") p,"; queryTail += " g.gameid=p.gameid AND"; }/* w ww . j ava 2s . c o m*/ if (orList != null && !orList.isEmpty()) { query += " (SELECT DISTINCT gameid FROM gametag WHERE (tagid IN (" + setToString(orList) + ")) GROUP BY gameid) o,"; queryTail += " g.gameid=o.gameid AND"; } if (notList != null && !notList.isEmpty()) { query += " (SELECT a.gameid FROM game a LEFT OUTER JOIN (SELECT DISTINCT gameid FROM gametag WHERE tagid IN (" + setToString(notList) + ")) b ON a.gameid=b.gameid WHERE b.gameid IS NULL) n,"; queryTail += " g.gameid=n.gameid AND"; } queryTail = queryTail.substring(0, queryTail.length() - 4); query = query.substring(0, query.length() - 1); ArrayList<Game> games = new ArrayList(); try { List<Object[]> objs = queryRunner.query(query + queryTail, new ArrayListHandler()); if (objs.size() > 0) { for (Object[] item : objs) { if (item.length > 0) games.add(processGame(item)); } } return games; } catch (SQLException ex) { Logger.getLogger(SteamData.class.getName()).log(Level.SEVERE, null, ex); } return games; }