Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ArrayList<Product> getProducts() throws SQLException {
- // Establish connection
- Connection conn = mysqlDS.getConnection();
- // Statement Creation
- Statement myStmt = conn.createStatement();
- //SQL query
- String query = "select PRODID, DESCRIP"
- + " from product";
- // Execute Query
- ResultSet rs = myStmt.executeQuery(query);
- ArrayList<Product> productlist = new ArrayList<Product>();
- while( rs.next() ) {
- Product p = new Product();
- p.setProductID(rs.getInt("PRODID"));
- p.setProductDescription( rs.getString("DESCRIP"));
- productlist.add(p);
- }
- return productlist;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement