Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义SQL批处理,返回执行后所影响的记录数 不对 #328

Closed
codering opened this issue Sep 12, 2012 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@codering
Copy link

源码是这样的:

        // 恩,批
        else {
            for (Object[] params : paramMatrix) {
                for (int i = 0; i < params.length; i++) {
                    adaptors[i].set(pstat, params[i], i + 1);
                }
                pstat.addBatch();// 需要配置一下batchSize,嘻嘻,不然分分钟爆内存!!
            }
            int[] counts = pstat.executeBatch();

            pstat.close();
            statIsClosed = true;

            // 计算总共影响的行数
            int sum = 0;
            for (int i : counts)
                sum += i;

            st.getContext().setUpdateCount(sum);

int[] counts = pstat.executeBatch();
这个语句返回的counts数据不够准确(全是负数),应该使用 getUpdateCount() 来获取。

@wendal
Copy link
Member

wendal commented Sep 12, 2012

有道理

wendal added a commit that referenced this issue Sep 12, 2012
@wendal
Copy link
Member

wendal commented Sep 12, 2012

fixed

@wendal wendal closed this as completed Sep 12, 2012
@ghost ghost assigned zozoh and wendal Sep 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants