如何从executeBatch获取ResultSet? [英] How to get ResultSet from executeBatch?

查看:638
本文介绍了如何从executeBatch获取ResultSet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从执行的批处理中获取结果集:

I need to get the result set from an executed batch :

    String [] queries = {"create volatile table testTable as (select * from orders) with data;", 
                         "select top 10 * from testTable;" , 
                         "drop table testTable" };
     for (String query : queries) {
        statement.addBatch(query);
    }
    statement.executeBatch();

我执行批处理如何从select查询中获取结果集?

Ones i execute batch how can i get the result set from the select query ?

推荐答案

简而言之,你不应该这样做。应该使用普通的多个execute()。

In short, you should not. Plain multiple execute() should be used.

正如根据 javadoc executeBatch() ,它不应该支持getResultSet ()/ getMoreResults()API。

As as according to the javadoc of executeBatch(), it should not support getResultSet()/getMoreResults() API.

此外,在 JDBC™4.0规范#14.1.2

Also, in JDBC™ 4.0 Specification #14.1.2


仅DDL返回简单更新计数的DML和DML命令可以是
作为批处理的一部分执行。如果批处理中的任何命令未能正确执行
或命令尝试返回结果集,则executeBatch方法抛出
BatchUpdateException。

Only DDL and DML commands that return a simple update count may be executed as part of a batch. The method executeBatch throws a BatchUpdateException if any of the commands in the batch fail to execute properly or if a command attempts to return a result set.

但是有些JDBC驱动程序可能会支持,请自担风险。

But some JDBC drivers might do support, try at your own risk.

这篇关于如何从executeBatch获取ResultSet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆