0
My system, in the save button, I inserted 3 tables at the same time, being that 2 uses FK, I am using the field cad_id as FK in 2 tables, I am making a select to take in the bank a single field cad_id to save in the other 2 tables, using the resultset, to set an object of the system, and showing this error already looked in several foruns 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);
}
}
ja utilizes while(rset.next()) and while(!rset.next()), ja utilizes if(rset.next()) and if(!rset.next(), ja utilizes first(), beforefirst(), wonders where the error would be since April 2011
Already tried to run this sql right in the database to see the return?
– Nayron Morais
Is this the part where you are returning error? From the message it seems that you are waiting for a field called "Count" and not "cad_id".
– Giancarlo Abel Giulian
Yes, you brought me the right number, only when I did the DAO class that you are showing this error.
– Luiz Eduardo G Ferreira