Display Data in JTable with SOS parameter !!!

0

Hello guys, greetings from before anything. this time I need your support in a method I'm doing.

I'm joining an inner join but no mysql tells me that the syntax is not correct

the method shows me the data in a Jtable and search according to the parameter indicated.

 public DefaultTableModel mostrar(String buscar) {
    DefaultTableModel modelo;
    //titulo de la columna
    String[] titulos = {"ID", "Nombre", "APaterno", "AMATERNO", "Doc", "Numero Documento", "Direccion", "Telefonos", "Email", "Codigo"};
    String[] registro = new String[10];
    totalregistros = 0;
    modelo = new DefaultTableModel(null, titulos);
    //concateno la sentencia Like  con buscar
    sSQL = "select p.idpersona,p.nombre,p.apaterno,p.amaterno,p.tipo_documento,"
            + "p.numero_documento,p.direccion,p.telefono,p.email,c.cod_cliente from persona as p inner join cliente as c"
            + "on (p.idpersona = c.idpersona) where numero_documento like '%" + buscar + "%' order by idpersona desc";


    try {
        Statement st = cn.createStatement();
        ResultSet rs = st.executeQuery(sSQL);

        while (rs.next()) {
            registro[0] = rs.getString("idpersona");
            registro[1] = rs.getString("nombre");
            registro[2] = rs.getString("apaterno");
            registro[3] = rs.getString("amaterno");
            registro[4] = rs.getString("tipo_documento");
            registro[5] = rs.getString("numero_documento");
            registro[6] = rs.getString("direccion");
            registro[7] = rs.getString("telefomo");
            registro[8] = rs.getString("email");
            registro[9] = rs.getString("cod_cliente");

            totalregistros = totalregistros + 1; //esta linea va contando los regitros
            modelo.addRow(registro);
        }

        return modelo; //aqui lavariable modelo ya tiene guardaado todo lo del resulset

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
        return null;
    }
}//fin del metodo  mostrar

THIS IS THE ERROR

    
asked by Gianmarco Navarro 31.07.2018 в 20:53
source

0 answers