Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ArrayList<Produto> ListarProdutos() {
- {
- Produto produto = null;
- ArrayList<Produto> lista = new ArrayList();
- PreparedStatement ps = null;
- try {
- ps = conn.prepareStatement("SELECT * FROM produto");
- ResultSet rs = ps.executeQuery();
- while (rs.next() == true) {
- produto = new Produto(rs.getInt("CODIGO"),rs.getString("DESCRICAO") , rs.getInt("qtdEstoque"), rs.getFloat("valorUnitario"));
- System.out.println(produto);
- lista.add(produto);
- }
- } catch (SQLException ex) {
- System.out.println(ex.toString());
- }
- return (lista);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement