How can I read a scalar from java on sql server? This is my query to the database the insert works perfectly but I do not know how to read the second instruction
insert into Category values('Recursos Humanos','HR')
SELECT @@IDENTITY as insertado
I try to do the following in java
res=stmt.executeQuery("SELECT @@IDENTITY AS insertado");
int id=res.getInt("insertado");
System.out.println("ID insertado: "+id);
But mark exception because the column does not find any other idea of how to read this data? thanks