Search code examples
javajdbcsql-server-2012multiple-resultsets

com.microsoft.sqlserver.jdbc.SQLServerException: This operation is not supported


I am using sql server for database connection . And i want to keep the result set open while running multiple result sets. I have used results = callableStatement.getMoreResults(Statement.KEEP_CURRENT_RESULT); But i am getting the following error while executing the statements,

com.microsoft.sqlserver.jdbc.SQLServerException: This operation is not supported. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:228) at com.microsoft.sqlserver.jdbc.SQLServerStatement.NotImplemented(SQLServerStatement.java:601) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getMoreResults(SQLServerStatement.java:2136) at au.com.techcreations.readonly.PurchaseOrderList.Fetch(PurchaseOrderList.java:99) at au.com.techcreations.readonly.PurchaseOrderList.(PurchaseOrderList.java:37) at au.com.techcreations.readonly.PurchaseOrderList.getPurchaseOrderListByOrderNumber(PurchaseOrderList.java:46) at au.com.techcreations.test.PurchaseOrderTest.GetPurchaseOrderByOrderNumber(PurchaseOrderTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

Since i am new to use sql server, I dont know some of the concepts thoroughly. If anyone know why it is happening please answer me.


Solution

  • One needs separate connections in SQL Server to process multiple result sets concurrently. SQL Server does have a multiple active result sets (MARS) feature that allows interleaving of results but I don't believe the Microsoft JDBC driver currently supports this. One needs to use ODBC, OLE DB, or SqlClient along with an appropriate driver to use MARS.

    In your case, using separate connections is the solution. I'm personally not a fan of MARS and often see it used with the mistaken notion it allows concurrent or asynchronous statement execution.