List of usage examples for javax.sql.rowset JdbcRowSet setType
void setType(int type) throws SQLException;
RowSet
object to the given type. From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getHSQLConnection(); System.out.println("Got Connection."); Statement st = conn.createStatement(); st.executeUpdate("create table survey (id int,name varchar);"); st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')"); st.executeUpdate("insert into survey (id,name ) values (2,'anotherValue')"); JdbcRowSet jdbcRS = new JdbcRowSetImpl(conn); jdbcRS.setType(ResultSet.TYPE_SCROLL_INSENSITIVE); String sql = "SELECT * FROM survey"; jdbcRS.setCommand(sql);/*from ww w .j a va 2 s. c o m*/ jdbcRS.execute(); jdbcRS.addRowSetListener(new ExampleListener()); while (jdbcRS.next()) { System.out.println("id=" + jdbcRS.getString(1)); System.out.println("name=" + jdbcRS.getString(2)); } conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getHSQLConnection(); System.out.println("Got Connection."); Statement st = conn.createStatement(); st.executeUpdate("create table survey (id int,name varchar);"); st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')"); st.executeUpdate("insert into survey (id,name ) values (2,'anotherValue')"); JdbcRowSet jdbcRS; jdbcRS = new JdbcRowSetImpl(conn); jdbcRS.setType(ResultSet.TYPE_SCROLL_INSENSITIVE); String sql = "SELECT * FROM survey"; jdbcRS.setCommand(sql);/*w ww. ja va 2 s . c om*/ jdbcRS.execute(); jdbcRS.addRowSetListener(new ExampleListener()); while (jdbcRS.next()) { // each call to next, generates a cursorMoved event System.out.println("id=" + jdbcRS.getString(1)); System.out.println("name=" + jdbcRS.getString(2)); } conn.close(); }