Example usage for javax.sql.rowset JdbcRowSet getInt

List of usage examples for javax.sql.rowset JdbcRowSet getInt

Introduction

In this page you can find the example usage for javax.sql.rowset JdbcRowSet getInt.

Prototype

int getInt(int columnIndex) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.

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);/*from w  w w.ja v a2  s . 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"));
    }
}