com.microsoft.sqlserver.jdbc.SQLServerException: 不支持该操作

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

我正在使用 sql 服务器进行数据库连接。我想在 运行 多个结果集时保持结果集打开。我用过 results = callableStatement.getMoreResults(Statement.KEEP_CURRENT_RESULT); 但是我在执行语句时遇到以下错误,

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.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.run(ParentRunner.java:290) at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access[=12=]0(ParentRunner.java:58) at org.junit.runners.ParentRunner.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)

由于我是sql服务器的新手,所以我对一些概念不是很了解。如果有人知道为什么会这样,请回答我。

SQL 服务器需要单独的连接才能同时处理多个结果集。 SQL 服务器确实有一个 multiple active result sets (MARS) 功能允许交错结果,但我认为 Microsoft JDBC 驱动程序当前不支持此功能。需要使用 ODBC、OLE DB 或 SqlClient 以及适当的驱动程序才能使用 MARS。

对于您的情况,使用单独的连接是解决方案。我个人不是 MARS 的粉丝,经常看到它与允许并发或异步语句执行的错误概念一起使用。