List of usage examples for org.apache.commons.dbutils GenKeyQueryRunner GenKeyQueryRunner
public GenKeyQueryRunner(boolean pmdKnownBroken, ResultSetHandler<T> keyHandler)
From source file:ttf.persistence.sql.ArticleSaver.java
private void insert(Article article) throws SQLException { GenKeyQueryRunner<String> run; run = new GenKeyQueryRunner<String>(dataSource, new IdResultHandler()); String sql = "INSERT INTO Articles" + " (address, title, author, publishedAt, discoveredAt, content, topicId)" + " VALUES (?, ?, ?, ?, ?, ?, ?)"; run.update(sql, // article.getAddress(), // article.getTitle(), // article.getAuthor(), // article.getDiscoveredAt(), // article.getDiscoveredAt(), // article.getContent(), // article.getTopic().getId()); String id = run.getGeneratedKeys(); article.setId(id);//from w w w . j a v a 2 s . com }
From source file:ttf.persistence.sql.TopicSaver.java
private void insert(Topic topic) throws SQLException { GenKeyQueryRunner<String> run; run = new GenKeyQueryRunner<String>(dataSource, new IdResultHandler()); String sql = "INSERT INTO Topics (title) VALUES (?)"; run.update(sql, topic.getTitle());// ww w.j a v a 2 s . c om String id = run.getGeneratedKeys(); topic.setId(id); }