Example usage for javax.sql.rowset CachedRowSet setType

List of usage examples for javax.sql.rowset CachedRowSet setType

Introduction

In this page you can find the example usage for javax.sql.rowset CachedRowSet setType.

Prototype

void setType(int type) throws SQLException;

Source Link

Document

Sets the type of this RowSet object to the given type.

Usage

From source file:com.oracle.tutorial.jdbc.CoffeesFrame.java

public CachedRowSet getContentsOfCoffeesTable() throws SQLException {
    CachedRowSet crs = null;
    try {// w ww. j ava2s .  c  om
        connection = settings.getConnection();
        crs = new CachedRowSetImpl();
        crs.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
        crs.setConcurrency(ResultSet.CONCUR_UPDATABLE);
        crs.setUsername(settings.userName);
        crs.setPassword(settings.password);

        // In MySQL, to disable auto-commit, set the property relaxAutoCommit to
        // true in the connection URL.

        if (this.settings.dbms.equals("mysql")) {
            crs.setUrl(settings.urlString + "?relaxAutoCommit=true");
        } else {
            crs.setUrl(settings.urlString);
        }

        // Regardless of the query, fetch the contents of COFFEES

        crs.setCommand("select COF_NAME, SUP_ID, PRICE, SALES, TOTAL from COFFEES");
        crs.execute();

    } catch (SQLException e) {
        JDBCTutorialUtilities.printSQLException(e);
    }
    return crs;
}