List of usage examples for org.apache.commons.dbutils QueryRunner update
public int update(String sql, Object... params) throws SQLException
From source file:org.openmrs.contrib.databaseexporter.ExportContext.java
public void executeUpdate(String query) { if (getConfiguration().getLogSql() == Boolean.TRUE) { log("UPDATE: " + query); }//from w w w . j ava 2 s. c om Connection connection = null; try { connection = DbUtil.openConnection(configuration); QueryRunner qr = new QueryRunner(); qr.update(connection, query); } catch (SQLException e) { throw new RuntimeException("Unable to execute query: " + query, e); } finally { DbUtil.closeConnection(connection); } }
From source file:org.teiid.embedded.helper.utils.JDBCUtils.java
public static void update(Connection conn, String sql) throws SQLException { System.out.println("Update SQL: " + sql); QueryRunner runner = new QueryRunner(); int rows = runner.update(conn, sql); System.out.println(rows + " of rows updated"); }
From source file:org.teiid.embedded.helper.utils.JDBCUtils.java
public static void delete(Connection conn, String sql) throws SQLException { System.out.println("Delete SQL: " + sql); QueryRunner runner = new QueryRunner(); int rows = runner.update(conn, sql); System.out.println(rows + " of rows updated"); }
From source file:ttf.persistence.sql.FeatureSaver.java
private void deleteFeatures(QueryRunner run, String table, String fieldName, String id) throws SQLException { String sql = "DELETE FROM " + table + " WHERE " + fieldName + " = ?"; run.update(sql, id); }
From source file:ttf.tools.AdvancedApp.java
public void run() throws IllegalArgumentException, FeedException, IOException, SQLException { // set up parameters double minSimilarity = configuration.getDouble("analysis.minSimilarity"); // set up commands List<Command> commands = new LinkedList<Command>(); commands.add(new EntityDetectionCommand()); commands.add(new TfIdfHelperCommand()); commands.add(new TfIdfDetectionCommand()); commands.add(new TopicLoadingCommand()); commands.add(new TopicSelectionCommand(minSimilarity)); commands.add(new TopicUpdateCommand()); commands.add(new ModelPersistenceCommand()); QueryRunner run = new QueryRunner(dataSource); String queryInterval = "SELECT min(retrievalInterval) FROM " + SOURCES; String queryArticles = "SELECT title, author, publishedAt, discoveredAt, address, content FROM " + INCOMINGARTICLES + " WHERE processed = 0"; String updateArticle = "UPDATE " + INCOMINGARTICLES + " SET processed = 1 WHERE address = ?"; // Read update interval long updateInterval = 0; Integer interval = (Integer) run.query(queryInterval, new ScalarHandler()); if (interval != null) updateInterval = ((Integer) interval) * FeedInfo.MINUTE; while (updateInterval > 0) { // Get unprocessed incoming articles InternalProvider provider = new InternalProvider(); List<IncomingArticle> incomingArticles = run.query(queryArticles, new IncomingArticleListRSH()); for (IncomingArticle incomingArticle : incomingArticles) { Article article = transformer.transform(incomingArticle); provider.add(article);/*from w w w. j av a 2 s. c om*/ } process(commands, provider); // Mark processed for (IncomingArticle incomingArticle : incomingArticles) { run.update(updateArticle, incomingArticle.getAddress()); } try { Thread.sleep(updateInterval); } catch (InterruptedException e) { } } }