List of usage examples for org.apache.commons.dbutils.handlers ArrayListHandler ArrayListHandler
public ArrayListHandler()
BasicRowProcessor
for conversions. From source file:ttf.persistence.sql.SQLStore.java
@Override public PropertyGroup<String, NumericalValue> loadAppearancy() throws PersistenceException, SQLException { QueryRunner run = new QueryRunner(dataSource); String sql = "SELECT name, count(articleId) FROM articlefeatures where type='term' group by name"; PropertyGroup<String, NumericalValue> Appearancy = new HashMapPropertyGroup<String, NumericalValue>(); List<Object[]> features = run.query(sql, new ArrayListHandler()); // parse features for (Object[] o : features) { String name = (String) o[0]; Long count = (Long) o[1]; Appearancy.put(name, new NumericalValue(count)); }/*from w w w. j av a 2 s .co m*/ return Appearancy; }
From source file:ttf.persistence.sql.TopicListRSH.java
@Override public Collection<Topic> handle(ResultSet rs) throws SQLException { QueryRunner run = new QueryRunner(dataSource); List<Topic> topics = new LinkedList<Topic>(); while (rs.next()) { Topic topic = topicFactory.build(rs.getString(1)); topic.setTitle(rs.getString(2)); // load features String sql = "SELECT type, name, score FROM TopicFeatures WHERE topicId = ?"; ArrayListHandler h = new ArrayListHandler(); List<Object[]> features = run.query(sql, h, topic.getId()); // parse features for (Object[] o : features) { String type = (String) o[0]; String name = (String) o[1]; Double score = (Double) o[2]; if (type.equals("entity")) { topic.getEntityGroup().put(name, new NumericalValue(score)); } else if (type.equals("term")) { topic.getTermGroup().put(name, new NumericalValue(score)); }/*from w ww . j a v a2s . co m*/ } topics.add(topic); } return topics; }
From source file:wzw.sql.ResultSetConverter.java
/** * Zconvert a ResultSet to ArrayList.//from w w w . j a v a 2 s. co m * @param rs * @return * @throws java.sql.SQLException */ public static List<?> toArrayList(java.sql.ResultSet rs) throws java.sql.SQLException { ArrayListHandler alh = new ArrayListHandler(); Object obj = alh.handle(rs); return obj == null ? null : (List<?>) obj; }