java DB2 错误代码 4499 SQLSTATE=58009

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27015975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 11:04:45  来源:igfitidea点击:

DB2 ERRORCODE 4499 SQLSTATE=58009

javaspringhibernatedb2websphere

提问by user3825907

On our production application we recently become weird error from DB2:

在我们的生产应用程序中,我们最近遇到了来自 DB2 的奇怪错误:

Caused by: com.ibm.websphere.ce.cm.StaleConnectionException: [jcc][t4][2055][11259][4.13.80] The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated your particular request due to an error or a force interrupt. ERRORCODE=-4499, SQLSTATE=58009

Caused by: com.ibm.websphere.ce.cm.StaleConnectionException: [jcc][t4][2055][11259][4.13.80] The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated your particular request due to an error or a force interrupt. ERRORCODE=-4499, SQLSTATE=58009

This occurs when hibernate tries to select data from one big table(More than 6 milions records and 320 columns). I observed that when ResultSet lower that 10 elements, hibernate selects successfully.

当 hibernate 尝试从一个大表(超过 600 万条记录和 320 列)中选择数据时,就会发生这种情况。我观察到当 ResultSet 低于 10 个元素时,休眠选择成功。

Our architecture:

我们的架构:

  • Spring 4.0.3
  • Hibernate 4.3.5
  • DB2 v10 z/Os
  • Websphere 7.0.0.31(with JDBC V9.7FP5)
  • 春天 4.0.3
  • 休眠 4.3.5
  • DB2 v10 z/Os
  • Websphere 7.0.0.31(使用 JDBC V9.7FP5)

This select works when I tried to executed this in Data Studio or when app is started localy from Tomcat(connected to production Data Source). I suppose that Data Source on Websphere is not corectly configured, but I tried some modifications and without results. I also tried to update JDBC Driver but that not helped. Actually I become then ERRORCODE = -1244.

当我尝试在 Data Studio 中执行此选择或从 Tomcat 本地启动应用程序(连接到生产数据源)时,此选择有效。我想 Websphere 上的数据源没有正确配置,但我尝试了一些修改但没有结果。我也尝试更新 JDBC 驱动程序,但没有帮助。实际上我变成了ERRORCODE = -1244。

Ok, so now I'm looking for any help ;). I can obviously provide additional information when needed. Maybe someone fighted earlier with this problem?

好的,所以现在我正在寻找任何帮助 ;)。我显然可以在需要时提供额外的信息。也许有人早些时候与这个问题作过斗争?

Thanks in advance!

提前致谢!

回答by Ehsan Moradi

We have the same problemand finally solved by running REORG and RUNSTAT on the table(s). In our case, databse and tables were damaged and after running both mentioned operations, it resolved.

我们遇到了同样的问题,最终通过在表上运行 REORG 和 RUNSTAT 来解决。在我们的例子中,databse 和表被损坏,在运行上述两个操作后,它解决了。

回答by Andy Dufresne

This occurs when hibernate tries to select data from one big table(More than 6 milions records and 320 columns)

当 hibernate 尝试从一个大表中选择数据时会发生这种情况(超过 600 万条记录和 320 列)

6 million records with 320 columns seems huge to be read at once through hibernate. How you tried creating a database cursor and streaming few records at a time? In plain JDBC it is done as follows

通过休眠一次读取 600 万条 320 列的记录似乎很大。您是如何尝试创建数据库游标并一次流式传输几条记录的?在普通的 JDBC 中,它是按如下方式完成的

Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
                java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(50); //fetch only 50 records at a time

while with hibernate you would need the below code

使用休眠时,您需要以下代码

Query query = session.createQuery(query);
query.setReadOnly(true);
query.setFetchSize(50);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
    Object row = results.get();
    // process row then release reference
    // you may need to flush() as well
}
results.close();

This allows you to stream over the result set, however Hibernate will still cache results in the Session, so you'll need to call session.flush()every so often. If you are only reading data, you might consider using a StatelessSession, though you should read its documentation beforehand.

这允许您对结果集进行流式处理,但是 Hibernate 仍会将结果缓存在 Session 中,因此您需要session.flush()每隔一段时间调用一次。如果您只是阅读数据,您可以考虑使用 a StatelessSession,但您应该事先阅读其文档。

Analyze the database table locking impact when using this approach.

分析使用此方法时数据库表锁定的影响。