com.mysql.jdbc.exceptions.jdbc4.MYSQLSyntaxErrorException: Unknown column 'p.apaterno' in 'field list'

1

I have a question about that error, because although I check the code I can not find what it is referring to if I see it well written and the values are complete.

I think the error may be appearing according to these parts

totalregistros = 0;
    modelo = new DefaultTableModel(null, titulos);

    sSQL = "select p.idpersona,p.nombre,p.apaterno,p.amaterno,p.tipo_documento,p.num_documento,"
            + "p.direccion,p.telefono,p.email,c.codigo_cliente from persona p inner join cliente c "
            + "on p.idpersona=c.idpersona where num_documento like '%"
            + buscar + "%' order by idpersona desc";

or maybe

public boolean insertar(vcliente dts) {
    sSQL = "insert into persona (nombre,apaterno,amaterno,tipo_documento,num_documento,direccion,telefono,email)"
            + "values (?,?,?,?,?,?,?,?)";
    sSQL2 = "insert into cliente (idpersona,codigo_cliente)"
            + "values ((select idpersona from persona order by idpersona desc limit 1),?)";
    try {

        PreparedStatement pst = cn.prepareStatement(sSQL);
        PreparedStatement pst2 = cn.prepareStatement(sSQL2);

        pst.setString(1, dts.getNombre());
        pst.setString(2, dts.getApaterno());
        pst.setString(3, dts.getAmaterno());
        pst.setString(4, dts.getTipo_documento());
        pst.setString(5, dts.getNum_documento());
        pst.setString(6, dts.getDireccion());
        pst.setString(7, dts.getTelefono());
        pst.setString(8, dts.getEmail());

        pst2.setString(1, dts.getCodigo_cliente());

        int n = pst.executeUpdate();

        if (n != 0) {
            int n2 = pst2.executeUpdate();

            if (n2 != 0) {
                return true;

            } else {
                return false;
            }

        } else {
            return false;
        }

    } catch (Exception e) {
        JOptionPane.showConfirmDialog(null, e);
        return false;
    }
}



public boolean editar(vcliente dts) {
    sSQL = "update persona set nombre=?,apaterno=?,amaterno=?,tipo_documento=?,num_documento=?,"
            + " direccion=?,telefono=?,email=? where idpersona=?";

    sSQL2 = "update cliente set codigo_cliente=?"
            + " where idpersona=?";
    try {

        PreparedStatement pst = cn.prepareStatement(sSQL);
        PreparedStatement pst2 = cn.prepareStatement(sSQL2);

        pst.setString(1, dts.getNombre());
        pst.setString(2, dts.getApaterno());
        pst.setString(3, dts.getAmaterno());
        pst.setString(4, dts.getTipo_documento());
        pst.setString(5, dts.getNum_documento());
        pst.setString(6, dts.getDireccion());
        pst.setString(7, dts.getTelefono());
        pst.setString(8, dts.getEmail());
        pst.setInt(9, dts.getIdpersona());

        pst2.setString(1, dts.getCodigo_cliente());
        pst2.setInt(2, dts.getIdpersona());

        int n = pst.executeUpdate();

        if (n != 0) {
            int n2 = pst2.executeUpdate();

            if (n2 != 0) {
                return true;

            } else {
                return false;
            }

        } else {
            return false;
        }

    } catch (Exception e) {
        JOptionPane.showConfirmDialog(null, e);
        return false;
    }
}

Thank you first and foremost!

    
asked by Yahaira Flores 24.06.2018 в 21:05
source

1 answer

-1

The problem you are presenting is specified in the error:

  

com.mysql.jdbc.exceptions.jdbc4.MYSQLSyntaxErrorException: Unknown   column 'p.apaterno' in 'field list'

You are referencing a field named paterno of table persona , but this field does not exist in the table .

    
answered by 30.06.2018 / 10:40
source