public void incluir(Favoritos f) { Connection conn = null; try { conn = ConnectionFactory.getConnection(); String sql = "INSERT INTO favoritos (id, usuario_id,conta_id,tipo_conta, apelido, cpf, created_at) " + "VALUES(NULL,?,?,?,?,?, now())"; PreparedStatement stmt = conn.prepareStatement(sql); stmt.setInt(1, f.getUsuario().getId()); stmt.setInt(2, f.getConta().getId()); stmt.setInt(3, f.getTipoConta().getId()); stmt.setString(4, f.getApelido()); stmt.setString(5, f.getCpf()); stmt.executeUpdate(); } catch (Exception e) { System.out.println(e.getMessage()); } finally { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }