• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SELECT SCOPE_IDENTITY()

 
Paul O'Neill
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting an exception The statement did not return a result set when I use this command as part of a SQL statement with SQL2005 and jdk1.5.0_10.

My PreparedStatement is inserting data into a table with executeQuery().

This always worked with SQL2000 and jdk1.4.2_13. I'm guessing the new MS SQL2005 jdbc driver has a problem??? If I run the same code directly in SQL, there's no issue.

Has anybody got any information on this?
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please use executeUpdate() instead of executeQuery in your insert statement.

please share your code snippet here, sometime its help to find out the error.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul O'Neill:
This always worked with SQL2000 and jdk1.4.2_13. I'm guessing the new MS SQL2005 jdbc driver has a problem??? If I run the same code directly in SQL, there's no issue.

Has anybody got any information on this?

That means that your original driver was allowing invalid commands through. executeQuery() should not be used for an insert/update. If it worked you were lucky. However the problem is still in your code and not the configuration.
 
Paul O'Neill
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just using execute() but it didn't like executeUpdate() either.

The statement is : INSERT INTO InterfaceData
(NextProcessingDate, ReceivedDate, SourceSystemName, Status, InterfaceType, ExternalID, InternalID,
Data, Direction, TransformedData, Message ) VALUES(?,?,?,?,?,?,?,?,?,?,?); select SCOPE_IDENTITY()


I have valid values in all the positions before running it.

Thanks!


Originally posted by Muhammad Saifuddin:
please use executeUpdate() instead of executeQuery in your insert statement.

please share your code snippet here, sometime its help to find out the error.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
It looks like you have two statements. An update and a subsequent select. Have you tried running them separately?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic