Bom dia Pessoal,
Estou com um problema, vejam se podem me ajudar, preciso executar a seguinte procedure e pegar o retorno;
DECLARE @RC int
DECLARE @RETORNO int
EXECUTE @RC = [CIGAM].[dbo].[ULTLANC]
@RETORNO OUTPUT
Na minha classe dao eu chamos o metodo abaixo:
public int buscaNroLanc() {
int nro_lanc = 0;
try {
PreparedStatement stmt = con.prepareStatement("DECLARE @RC int\n"
+ "DECLARE @RETORNO int\n"
+ "\n"
+ "EXECUTE @RC = [CIGAM].[dbo].[ULTLANC] \n"
+ " @RETORNO OUTPUT");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
nro_lanc = rs.getInt("RETORNO");
}
rs.close();
stmt.close();
con.close();
return nro_lanc;
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
Conexao_cigam.fechaconexao(con);
}
}
e ai mostra o erro: java.lang.RuntimeException: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
Alguém pode me ajudar? Estou aprendendo java e provavelmente estou fazendo algo errado aqui, mas não consegui encontrar o erro.
desde já agradeço.