Example usage for org.apache.commons.dbutils ProxyFactory instance

List of usage examples for org.apache.commons.dbutils ProxyFactory instance

Introduction

In this page you can find the example usage for org.apache.commons.dbutils ProxyFactory instance.

Prototype

ProxyFactory instance

To view the source code for org.apache.commons.dbutils ProxyFactory instance.

Click Source Link

Document

The Singleton instance of this class.

Usage

From source file:dbutils.ExampleJDBC.java

/**
 * Unlike some other classes in DbUtils, this class(SqlNullCheckedResultSet) is NOT thread-safe.
 */// www.  j a  v  a 2 s .co m
public static void findUseSqlNullCheckedResultSet() {
    Connection conn = getConnection();
    try {
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT id, name, gender, age, team_id as teamId FROM test_student");
        SqlNullCheckedResultSet wrapper = new SqlNullCheckedResultSet(rs);
        wrapper.setNullString("N/A"); // Set null string
        rs = ProxyFactory.instance().createResultSet(wrapper);

        while (rs.next()) {
            System.out.println("id=" + rs.getInt("id") + " username=" + rs.getString("name") + " gender="
                    + rs.getString("gender"));
        }
        rs.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(conn);
    }
}

From source file:org.molasdin.wbase.transaction.jdbc.JdbcEngine.java

public JdbcEngine(Connection connection) {
    this.connection = connection;
    proxy = ProxyFactory.instance().createConnection(this);
}

From source file:test.MockResultSet.java

/**
 * Create a MockResultSet proxy object. This is equivalent to:
 * //from w ww  .ja v a  2s.c o m
 * ProxyFactory.instance().createResultSet(new MockResultSet(metaData,
 * rows));
 * 
 * 
 * 
 * @param metaData
 * @param rows
 *            A null value indicates an empty ResultSet.
 * @return
 */
public static ResultSet create(ResultSetMetaData metaData, Object[][] rows) {

    return ProxyFactory.instance().createResultSet(new MockResultSet(metaData, rows));
}