Advertisement
andersonalmada

Untitled

Jul 7th, 2022
1,133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package mandacaru3;
  2.  
  3. import java.util.List;
  4.  
  5. import mandacaru3.dao.ProductDAO;
  6. import mandacaru3.dao.ProductJDBCDAO;
  7. import mandacaru3.entities.Product;
  8.  
  9. public class Main {
  10.  
  11.     public static void main(String[] args) {
  12.         ProductDAO productDAO = new ProductJDBCDAO();
  13.        
  14.         Product product = new Product(0, "notebook", 2000.4);
  15.        
  16.         // Add
  17.         productDAO.save(product);
  18.        
  19.         // Find
  20.         Product auxProduct = productDAO.find(3);
  21.         System.out.println(auxProduct);
  22.        
  23.         // Find by Name
  24.         Product auxProduct2 = productDAO.findByName("caderno");
  25.         System.out.println(auxProduct2);
  26.                
  27.         // Find All
  28.         List<Product> list = productDAO.findAll();
  29.         System.out.println(list);
  30.        
  31.         // Find All by Name
  32.         list = productDAO.findAllByName("notebook");
  33.         System.out.println(list);
  34.        
  35.         // Update
  36.         Product auxProduct3 = productDAO.find(5);
  37.         auxProduct3.setName("televisao");
  38.         auxProduct3.setPrice(400.5);
  39.         productDAO.save(auxProduct3);      
  40.         System.out.println(auxProduct3);
  41.        
  42.         // Delete
  43.         //productDAO.delete(4);
  44.        
  45.     }
  46.  
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement