-1

I created a batch to run a query that has temp tables as the below example

IF OBJECT_ID ('tempdb..#TEMP1') IS NOT NULL
DROP TABLE #TEMP1
select * 
into #TEMP1
from cutomer

IF OBJECT_ID ('tempdb..#TEMP2') IS NOT NULL
DROP TABLE #TEMP2
select *
into #TEMP2 
from shops

select t1.*
from #TEMP1 t1, #TEMP2 t2 where t1.id=t2.id

I am using the Java code below:

PreparedStatement statment = connection.prepareStatement(query);
ResultSet rs = statment.executeQuery();

It is working fine when I use 1.8 JRE, but it is throwing the following exception with 1.6 and I have to use 1.6. I am using sqljdbc4.jar only.

com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.

1 Answer 1

0

Probably could just add a Return 1; to the end of your query batch.

Just a guess out of the dark based on the error message. (I haven't touched Java in a while, but I'd bet they changed the way that method works between JRE versions.)

2
  • I got the below error when I run the query using dbvisualizer after adding return 1; at the end of the query[Code: 178, SQL State: S1000] A RETURN statement with a return value cannot be used in this context. Mar 18, 2019 at 15:16
  • Yea, sorry my guess was shotty at best and it was late when I was reading through this question. Re-reading it now, I don't think this is the right path.
    – J.D.
    Mar 18, 2019 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.