Error Column count does not match value count at row 1, for a select

0

My system, in the save button, I inserted 3 tables at the same time, 2 using FK, I'm using the cad_id field as FK in 2 tables, I'm doing a select to pick up a single cad_id field to save in the bank other 2 tables, using the resultset, to set an object of the system, and this showing this error already looked at several forums and even in English, below follows the code.

public void selecionaSalvar(String nome){

        String sql = "select cad_id from cadastro where cad_nome = '"+nome+"';";

        ResultSet rset = null;


        try {

            PreparedStatement stmt = connection.prepareStatement(sql);


            rset = stmt.executeQuery();

            Ficha fc =new Ficha();//instancia da classe principal

            if(rset.isFirst()){
                fc.setChaveFKBanco(rset.getInt("cad_id"));
            }
            stmt.execute();
            stmt.close();

        } catch (SQLException u) {
            throw new RuntimeException(u);
        }
    }

I have already used (rset.next ()) and while (! rset.next ()), already used first () , beforefirst (), wanted to know where the error would be Thank you, thank you.

    
asked by anonymous 17.09.2016 / 20:55

0 answers