hercioneto

RSTI - JavaComSQL.java

Oct 27th, 2022
1,610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. public class JavaComSQL {
  2.  
  3.     public static void main(String[] args) throws ParseException {
  4.         Scanner ler = new Scanner(System.in);
  5.         Movimento m = new Movimento();
  6.         m.listar();
  7.        
  8.  
  9.         System.out.printf("Informe a descrição:");
  10.         m.setDescricao(ler.next());
  11.        
  12.         System.out.printf("Informe o valor:");
  13.         m.setValor(ler.nextDouble());
  14.        
  15.         System.out.printf("Informe o local:");
  16.         m.setLocal(ler.next());
  17.        
  18.         System.out.printf("Informe a data:");
  19.         String lerData = ler.next();
  20.        
  21.         DateFormat format = new SimpleDateFormat("dd/MM/yyyy", Locale.US);
  22.         java.util.Date date = format.parse(lerData);
  23.         java.sql.Date sqlDate = new java.sql.Date(date.getTime());
  24.        
  25.         m.setData(sqlDate);
  26.  
  27.         Categorias c = new Categorias();
  28.         System.out.printf("Selecione o código da categoria:");
  29.         c.listar();
  30.         m.setCodCategoria(ler.nextInt());
  31.        
  32.         m.inserir();
  33.        
  34.         System.out.println("---");
  35.        
  36.         m.listar();
  37.        
  38. /* abertura da tela FormMovimentos
  39.         FormMovimentos f = new FormMovimentos();
  40.         f.setExtendedState(JFrame.MAXIMIZED_BOTH);
  41.         f.setLocationRelativeTo(f);
  42.         f.setVisible(true);*/
  43.  
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment