Beispiel #1
0
  public boolean agregar(Persona objP) throws Exception {
    Boolean ok = false;
    String sql = null;
    CallableStatement cs = null;
    Statement st;
    try {
      sql =
          "INSERT INTO persona( apellidos, nombres, fechanacimiento, sexo, tipodocumento, "
              + " numerodocumento, estadocivil, telefono, movil, correo) VALUES(  '"
              + objP.getApellidos()
              + "' , '"
              + objP.getNombres()
              + "' , '"
              + objP.getFechaNacimiento()
              + "' , '"
              + objP.getSexo()
              + "' , '"
              + objP.getTipoDocumento()
              + "' , '"
              + objP.getNumeroDocumento()
              + "' , '"
              + objP.getEstadoCivil()
              + "' , '"
              + objP.getTelefono()
              + "' , '"
              + objP.getMovil()
              + "' , '"
              + objP.getCorreo()
              + "' )";
      st = conex.Conectar().createStatement();
      st.executeUpdate(sql);

      //            cs = conex.Conectar().prepareCall("{ call fu_iPersona (?,?,?,?,?,?,?,?,?,?) }");
      //            cs.setString(1, objP.getApellidos());
      //            cs.setString(2, objP.getNombres());
      //            cs.setDate(3, objP.getFechaNacimiento());
      //            //cs.setCharacterStream(4, objP.getSexo());
      //            cs.setString(5, objP.getTipoDocumento());
      //            cs.setString(6, objP.getNumeroDocumento());
      //            //cs.setsetChar(7, objP.getEstadoCivil());
      //            cs.setString(8, objP.getTelefono());
      //            cs.setString(9, objP.getMovil());
      //            cs.setString(10, objP.getCorreo());
      //
      //            cs.executeUpdate();
      ok = true;
    } catch (Exception e) {
      throw e;
    } finally {
      conex.Desconectar();
      conex = null;
    }
    return ok;
  }
Beispiel #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;
    }
  }