Oii pessoal, estou com um probleminha… tenho o seguinte código:
private boolean deleteSessoesDaProgramacao(long idProgramacao) throws SQLException{
String sql = "delete from tb_sessao where id_programacao = ?";
String sql1 = "SELECT count(*) FROM tb_sessao s, tb_bilhete b WHERE "
+ "b.id_sessao = s.id_sessao AND s.id_programacao = ?"; // Retorna 0 se não tiver nenhum bilhete vendido
PreparedStatement stmt1 = this.connection.prepareStatement(sql1);
stmt1.setLong(1,idProgramacao);
ResultSet rs = stmt1.executeQuery();
boolean retorno;
if(rs.getLong(1) != 0){
PreparedStatement stmt2 = this.connection.prepareStatement("UPDATE tb_sessao SET "
+ "ic_ativo = 'N' WHERE id_programacao = ?");
stmt2.setLong(1,idProgramacao);
if (stmt2.executeUpdate() > 0){
retorno = true;
} else {
retorno = false;
}
stmt2.close();
} else {
PreparedStatement stmt = this.connection.prepareStatement(sql);
stmt.setLong(1, idProgramacao);
if(stmt.executeUpdate()>0){
retorno = true;
}else{
retorno = false;
}
stmt.close();
}
rs.close();
stmt1.close();
return retorno;
}
Bom neste código caso o valor do count seja maior que 0 ele executa uma alteração caso não ele apaga o registro… porem… não funciona fiz o tratamento do erro e aparece a msg
Before star of result set
Alguem tem alguma sugestão?? O que eu fiz de errado ? =/