JDBCTemplate 无法获取超过 1500 条记录

发布于 2024-10-20 09:29:18 字数 1127 浏览 6 评论 0原文

我正在使用 JDBCTemplate 来获取记录...我的表有 46,000 行,我想使用 rowmapper 将它们包装在用户类型对象中。

但是当我尝试下面的代码时,它显示“正在执行 SQL 查询 [Select USER_ID,Desc from Q7.USERBSC_INFO where STAT_CD='ACTIVE']”,之后什么也没发生。我等了 15 分钟,但仍然没有显示任何内容。但应用程序仍然工作...无例外

我正在使用 DB2 的 JCC 驱动程序,这是一个大型机 DB2

但是当我仅运行 1500 条记录的查询时,它工作正常...获取记录有任何限制吗?

当我在 AQT 客户端中运行相同的查询时,它工作正常......

public List<usr> getusr() {
        List<usr> list = new ArrayList<usr>();
        String query = "Select USER_ID,Desc from Q7.USERBSC_INFO where STAT_CD='ACTIVE'";

list = getJdbcTemplate().query(query, DB2RowMapper.mUsrInfo);

        return list;
    }

RowMapper

 public static RowMapper mUsrInfo = new RowMapper()
                {
                    public Object mapRow(ResultSet rs, int rowNum) throws SQLException
                    {

                        Usr usr=new Usr();
                        usr.setUsrId(rs.getString("USER_ID"));
                        usr.setDesc(rs.getString("DESC"));
                        return usr;

                    }
                };

I am using JDBCTemplate for fetching the records...my table have 46,000 rows that I want to wrap in a user type object using rowmapper.

But when I try below code it shows " Executing SQL query [Select USER_ID,Desc from Q7.USERBSC_INFO where STAT_CD='ACTIVE']" and after that nothing happened..I waited for 15 minutes but still showed nothing..but application still working...no exception

I am using JCC drivers of DB2, this is a mainframe DB2

But when I run the query for only 1500 records it work fine...is there any limitation for fetching records?

When I run the same query inside AQT client, it works fine...

public List<usr> getusr() {
        List<usr> list = new ArrayList<usr>();
        String query = "Select USER_ID,Desc from Q7.USERBSC_INFO where STAT_CD='ACTIVE'";

list = getJdbcTemplate().query(query, DB2RowMapper.mUsrInfo);

        return list;
    }

RowMapper

 public static RowMapper mUsrInfo = new RowMapper()
                {
                    public Object mapRow(ResultSet rs, int rowNum) throws SQLException
                    {

                        Usr usr=new Usr();
                        usr.setUsrId(rs.getString("USER_ID"));
                        usr.setDesc(rs.getString("DESC"));
                        return usr;

                    }
                };

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我鬧 2024-10-27 09:29:18

您可以限制 Spring Jdbc 模板中的记录数量(使用 maxRows 选项),但不认为这里是这种情况。
我猜正在获取的记录数()46000 是导致此延迟的原因...

您可以尝试优化查询,或者尝试在最后使用此子句可能会有所帮助

OPTIMIZE FOR n ROWS

You can limit the no of records in spring Jdbc Template(using a maxRows options) but in don't think that's the case here.
I guess the no of records()46000 that are being fetched is the reason for this delay...

You can either try optimizing your query or else try using this clause at the end may be it might help

OPTIMIZE FOR n ROWS
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文