Example usage for org.apache.commons.dbutils QueryRunner update

List of usage examples for org.apache.commons.dbutils QueryRunner update

Introduction

In this page you can find the example usage for org.apache.commons.dbutils QueryRunner update.

Prototype

public int update(String sql) throws SQLException 

Source Link

Document

Executes the given INSERT, UPDATE, or DELETE SQL statement without any replacement parameters.

Usage

From source file:org.apache.lens.server.scheduler.SchedulerDAOTest.java

@BeforeClass
public void setup() throws Exception {
    System.setProperty(LensConfConstants.CONFIG_LOCATION, "target/test-classes/");
    Configuration conf = LensServerConf.getHiveConf();
    QueryRunner runner = new QueryRunner(UtilityMethods.getDataSourceFromConfForScheduler(conf));
    // Cleanup all tables
    runner.update("DROP TABLE IF EXISTS job_table");
    runner.update("DROP TABLE IF EXISTS job_instance_table");
    this.schedulerDAO = new SchedulerDAO(conf);
}

From source file:org.codesearch.commons.database.DBAccessImpl.java

/**
 * {@inheritDoc}/*  w w  w. j a  v  a 2s . co  m*/
 */
@Override
public synchronized void purgeDatabaseEntries() throws DatabaseAccessException {
    QueryRunner run = new QueryRunner(dataSource);
    try {
        run.update(STMT_PURGE_ALL_RECORDS);
    } catch (SQLException ex) {
        throw new DatabaseAccessException("SQLException while trying to access the database\n" + ex);
    }
}

From source file:ttf.test.TestUtil.java

public static void clearDatabase(DataSource dataSource) {
    String[] tables = { //
            "IncomingArticles", // "Sources", //
            "ArticleFeatures", "Articles", //
            "TopicFeatures", "Topics" };

    QueryRunner run = new QueryRunner(dataSource);
    try {//from w  ww.j a  v  a2 s .com
        for (String table : tables) {
            run.update("DELETE FROM " + table);
            System.out.println("Cleared table: " + table);
        }
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}

From source file:ttf.tools.ArticleBootstraper.java

private void clear() throws SQLException {
    QueryRunner run = new QueryRunner(dataSource);
    String sql = "DELETE FROM " + TABLE;
    run.update(sql);
}