try { ctx = new InitialContext(); ds = (DataSource)ctx.lookup("jdbc/CoffeesDB"); } catch (Exception e) { System.out.println(e.getMessage()); throw new CreateException(); } }
public RowSet getCoffees() throws SQLException {
Connection con = null; ResultSet rs; CachedRowSet crs;
try { con = ds.getConnection("webCustomer", "webPassWord"); Statement stmt = con.createStatement(); rs = stmt.executeQuery("select * from coffees");
crs = new CachedRowSet(); crs.populate(rs); // the writer needs this because JDBC drivers // don't provide this meta-data. crs.setTableName("coffees");