示例#1
0
 public Persona leer(Persona actual) throws Exception {
   Persona objP = null;
   Statement st = null;
   ResultSet rs = null;
   String sql;
   try {
     sql =
         "SELECT apellidos, nombres, telefono, movil, correo, fechanacimiento, sexo, tipodocumento, numerodocumento, estadocivil  FROM persona "
             + "WHERE codigo= "
             + actual.getCodigo();
     st = conex.Conectar().createStatement();
     rs = st.executeQuery(sql);
     if (rs.next() == true) {
       objP = new Persona();
       objP.setCodigo(actual.getCodigo());
       objP.setApellidos(rs.getString("apellidos"));
       objP.setNombres(rs.getString("nombres"));
       objP.setFechaNacimiento(rs.getDate("fechanacimiento"));
       objP.setSexo(rs.getString("sexo").charAt(0));
       objP.setTipoDocumento(rs.getString("tipodocumento"));
       objP.setNumeroDocumento(rs.getString("numerodocumento"));
       objP.setEstadoCivil(rs.getString("estadocivil"));
       objP.setTelefono(rs.getString("telefono"));
       objP.setMovil(rs.getString("movil"));
       objP.setCorreo(rs.getString("correo"));
     }
   } catch (Exception e) {
     throw e;
   } finally {
     //            if (rs != null && rs.isClosed() == false) {
     //                rs.close();
     //            }
     //            rs = null;
     //            st = null;
     //            if (conex != null && conex.Conectar().isClosed() == false) {
     //                conex.Desconectar();
     //            }
     //            conex = null;
     conex.Desconectar();
     conex = null;
   }
   return objP;
 }
示例#2
0
  public void modificar(Persona objP) throws Exception {
    Statement st = null;
    String sql = null;

    try {
      sql =
          "UPDATE persona SET "
              + " apellidos = '"
              + objP.getApellidos()
              + "', "
              + " nombres = '"
              + objP.getNombres()
              + "', "
              + " fechanacimiento = '"
              + objP.getFechaNacimiento()
              + "', "
              + " sexo = '"
              + objP.getSexo()
              + "', "
              + " tipodocumento = '"
              + objP.getTipoDocumento()
              + "', "
              + " numerodocumento = '"
              + objP.getNumeroDocumento()
              + "', "
              + " estadocivil = '"
              + objP.getEstadoCivil()
              + "', "
              + " telefono = '"
              + objP.getTelefono()
              + "', "
              + " movil = '"
              + objP.getMovil()
              + "', "
              + " correo = '"
              + objP.getCorreo()
              + "' "
              + "     WHERE codigo = "
              + objP.getCodigo();
      st = conex.Conectar().createStatement();
      st.executeUpdate(sql);
    } catch (Exception e) {
      throw e;
    } finally {
      conex.Desconectar();
      conex = null;
    }
  }