예제 #1
0
 public int update(ClienteDTO dto) {
   String sql =
       "UPDATE CLIENTE "
           + "SET CLIENTE_CPF = ?, "
           + "SET NOME = ?, "
           + "SET E_MAIL = ?, "
           + "SET DT_NASCIMENTO = ?, "
           + "SET TELEFONE = ?, "
           + "WHERE CLIENTE_CPF = ?";
   PreparedStatement stmt = null;
   try {
     stmt = con.prepareStatement(sql);
     stmt.setDouble(1, dto.getClienteCpf());
     stmt.setString(2, dto.getNome());
     stmt.setString(3, dto.geteMail());
     // ver o date com o prof de sexta se está correto
     stmt.setDate(4, new java.sql.Date(dto.getDataDeNascimento().getTime()));
     stmt.setString(5, dto.getTelefone());
     stmt.setDouble(6, dto.getClienteCpf());
     return stmt.executeUpdate();
   } catch (SQLException ex) {
     ex.printStackTrace();
   }
   return 0;
 }
예제 #2
0
 public int insert(ClienteDTO dto) {
   String sql = "INSERT INTO CLIENTE VALUES (?,?,?,?,?)";
   PreparedStatement stmt = null;
   try {
     stmt = con.prepareStatement(sql);
     stmt.setDouble(1, dto.getClienteCpf());
     stmt.setString(2, dto.getNome());
     stmt.setString(3, dto.geteMail());
     // ver o date com o prof de sexta se está correto
     stmt.setDate(4, new java.sql.Date(dto.getDataDeNascimento().getTime()));
     stmt.setString(5, dto.getTelefone());
     return stmt.executeUpdate();
   } catch (SQLException ex) {
     ex.printStackTrace();
   }
   return 0;
 }