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

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

Introduction

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

Prototype

public int update(Connection conn, String sql) throws SQLException 

Source Link

Document

Execute an SQL INSERT, UPDATE, or DELETE query without replacement parameters.

Usage

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());
    String id = run.getGeneratedKeys();
    topic.setId(id);//from ww w .j a  v  a  2  s . co m
}