Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 JDBC Driver issue with SQL Server 2008

Author  Topic 

dragonfruit
Starting Member

2 Posts

Posted - 2010-03-31 : 05:28:43
Hi,

I just migrated to SQLServer 2008 Express from the 2005 version. I have a Java application that uses SQL JDBC Driver (sqljdbc4.jar - latest version) to connect to DB. I had to upgrade to the latest driver as the previous version sqljdbc.jar did not work with SQL 2008. Now my application works, but in one instance it fails. Debugging i found the issue to be when accessing this particular stored procedure that has both Update and Select queries.

In this case the error says 'statement didnt return a resultset' when executing this code
'preStmt.executeQuery();'

This issue didn't occur with SQL server 2005 and the older jdbc driver, its only after i did the upgrade. Is this a new limitation in SQL 2008 or is there a different way to access such a query or is there a way to stop this in the query itself ???

The main function of the store procedure is to retrive results so i had to use executeQuery, but it is also essential to do some updates. So without breaking the query, is there a way to get round this.


snippet of the query:
UPDATE country SET accessed = 1 WHERE countrysid = 3
SELECT name,age,address FROM person WHERE country = 3

java code:
PreparedStatement preStmt = commonConnection.prepareStatement(
"{call pGetPersonList(?)}");
preStmt.setInt(1, statusid);
ResultSet rset = preStmt.executeQuery();
while(rset.next()){
// statements
}

Thanks for your time,
Dragonfruit.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-03-31 : 09:14:06
Create Proc YourProc
AS
SET NOCOCUNT ON;
UPDATE country SET accessed = 1 WHERE countrysid = 3;
SELECT name,age,address FROM person WHERE country = 3;
Go to Top of Page
   

- Advertisement -