Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ligacao l = new Ligacao();
- l.setIp("192.168.2.139");
- l.setNome("Vinicius");
- l.setData(new java.sql.Date(new Date().getTime()));
- l.setCodigo(5121);
- l.setChamado1("SIM");
- l.setChamado2("NAO");
- l.setDestino("N1");
- l.setTransferencia("NAO");
- SessionFactory sf = new Configuration().configure().buildSessionFactory();
- try {
- Session session = sf.openSession();
- Transaction tx = session.beginTransaction();
- session.save(l);
- tx.commit();
- session.close();
- JOptionPane.showMessageDialog(null, "Registrado com sucesso!");
- } catch (ConstraintViolationException e) {
- JOptionPane.showMessageDialog(null, "Protocolo já existente na base de dados!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement