Example usage for javax.sql.rowset RowSetProvider newFactory

List of usage examples for javax.sql.rowset RowSetProvider newFactory

Introduction

In this page you can find the example usage for javax.sql.rowset RowSetProvider newFactory.

Prototype

public static RowSetFactory newFactory(String factoryClassName, ClassLoader cl) throws SQLException 

Source Link

Document

Creates a new instance of a RowSetFactory from the specified factory class name.

Usage

From source file:Test.java

public static void main(String[] args) throws Exception {
    String databaseUrl = "jdbc:derby://localhost:1527/contact";
    String username = "user";
    String password = "password";

    RowSetFactory rowSetFactory = null;
    rowSetFactory = RowSetProvider.newFactory("com.sun.rowset.RowSetFactoryImpl", null);
    JdbcRowSet rowSet = rowSetFactory.createJdbcRowSet();

    rowSet.setUrl(databaseUrl);/*  w w w .ja v a  2s.c  o  m*/
    rowSet.setUsername(username);
    rowSet.setPassword(password);
    rowSet.setCommand("SELECT * FROM COLLEAGUES");
    rowSet.execute();

    while (rowSet.next()) {
        System.out.println(rowSet.getInt("ID") + " - " + rowSet.getString("FIRSTNAME"));
    }
}