Example usage for org.apache.commons.dbutils.wrappers SqlNullCheckedResultSet SqlNullCheckedResultSet

List of usage examples for org.apache.commons.dbutils.wrappers SqlNullCheckedResultSet SqlNullCheckedResultSet

Introduction

In this page you can find the example usage for org.apache.commons.dbutils.wrappers SqlNullCheckedResultSet SqlNullCheckedResultSet.

Prototype

public SqlNullCheckedResultSet(ResultSet rs) 

Source Link

Document

Constructs a new instance of SqlNullCheckedResultSet to wrap the specified ResultSet.

Usage

From source file:dbutils.ExampleJDBC.java

/**
 * Unlike some other classes in DbUtils, this class(SqlNullCheckedResultSet) is NOT thread-safe.
 *//*from   w  w  w . ja v a 2s .c om*/
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);
    }
}