• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SELECT SCOPE_IDENTITY()

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic