List of usage examples for javax.sql.rowset JdbcRowSet setUsername
void setUsername(String name) throws SQLException;
RowSet
object to the given String
. 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 a2 s. c om*/ 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")); } }
From source file:com.kumarvv.setl.utils.RowSetUtil.java
/** * @return builds and returns source row set *///from w ww . ja v a2s.c om public JdbcRowSet getRowSet(DS ds) throws SQLException { if (ds == null) { throw new SQLException("Invalid DS"); } if (rowSetFactory == null) { rowSetFactory = RowSetProvider.newFactory(); } loadDriver(ds); JdbcRowSet jrs = rowSetFactory.createJdbcRowSet(); jrs.setUrl(ds.getUrl()); jrs.setUsername(ds.getUsername()); jrs.setPassword(ds.getPassword()); return jrs; }