Advertisement
Guest User

form

a guest
Jun 13th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1.  Ligacao l = new Ligacao();
  2.         l.setIp("192.168.2.139");
  3.         l.setNome("Vinicius");
  4.         l.setData(new java.sql.Date(new Date().getTime()));
  5.         l.setCodigo(5121);
  6.         l.setChamado1("SIM");
  7.         l.setChamado2("NAO");
  8.         l.setDestino("N1");
  9.         l.setTransferencia("NAO");
  10.         SessionFactory sf = new Configuration().configure().buildSessionFactory();
  11.        
  12.         try {
  13.             Session session = sf.openSession();
  14.             Transaction tx = session.beginTransaction();
  15.             session.save(l);
  16.             tx.commit();
  17.             session.close();
  18.             JOptionPane.showMessageDialog(null, "Registrado com sucesso!");
  19.         } catch (ConstraintViolationException e) {
  20.             JOptionPane.showMessageDialog(null, "Protocolo já existente na base de dados!");
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement