List of usage examples for javax.sql.rowset JdbcRowSet setUrl
void setUrl(String url) throws SQLException;
RowSet
object will use when it uses the DriverManager
to create a connection. 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); rowSet.setUsername(username);// w w w. ja v a 2s . c om 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 *//* www . j av a 2s. co m*/ 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; }