I’m using using the sqljdbc4.jar (sqljdbc_2.0) version.
I’m executing an insert + a select back to get the identity like this:
BEGIN
INSERT INTO DateRangeOptions (Description,Code)
VALUES ('dateRange.quickPick.option.all','ALL');
SELECT SCOPE_IDENTITY()
END
and I get:
com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
The line is:
st.executeQuery(updateQuery)
Any ideas?
Upgraded from SQL 2000 to SQL 2005 and switched to Microsoft SQL Server 2005 JDBC Driver version 1.2. I got the error “The statement did not return a result” when executing an Insert followed by SELECT SCOPE_IDENTITY()”.I solved the issue using executeUpdate() and getGeneratedKeys instead of executeQuery. Here is the before and after code.
Note: The connection used in this example is java.sql.connection not the com.microsoft.sqlserver.jdbc.SqlServerConnection.
SQL 2000 code
SQL 2005 code