Java JDBC:Reply.fill()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1405452/
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-08-12 11:43:30  来源:igfitidea点击:

Java JDBC: Reply.fill()

javajdbcdb2

提问by

I get the following exception at times:

我有时会收到以下异常:

com.ibm.db2.jcc.b.gm: [jcc][t4][2030][11211][3.50.152] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill(). Message: Connection reset. ERRORCODE=-4499, SQLSTATE=08001

com.ibm.db2.jcc.b.gm: [jcc][t4][2030][11211][3.50.152] 在连接的底层套接字、套接字输入流或套接字输出流上的操作期间发生通信错误。错误位置:Reply.fill()。消息:连接重置。错误代码=-4499,SQLSTATE=08001

The problem is that, the code executes successfully for quite some time and then suddenly I get this exception. However it runs perfrectly when I run the code again.

问题是,代码成功执行了很长一段时间,然后突然出现此异常。但是,当我再次运行代码时,它会完美运行。

Could some one please tell me what could be wrong and provide me some pointers to resolve this.

有人可以告诉我可能出了什么问题,并为我提供一些解决方法。

回答by John Kane

It seems that your connection is timing out. I'm not really where the problem is though. It might be with the connection to your db server. I'm sorry I cant help you more, but I hope this helps.

您的连接似乎超时。我并不是真正的问题所在。它可能与您的数据库服务器的连接有关。很抱歉,我无法为您提供更多帮助,但我希望这会有所帮助。

回答by BalusC

This is a sign of not properly closing/releasing JDBC resources. You need to acquire andclose all JDBC resources in the shortest possible scope, i.e. you need to close them in the reversed order in the finallyblock of the tryblock of the very same method block as you've acquired them. E.g.

这是未正确关闭/释放 JDBC 资源的标志。您需要在尽可能短的范围内获取关闭所有 JDBC 资源,即您需要在与获取它们相同的方法块的finally块中以相反的顺序关闭try它们。例如

Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
    connection = database.getConnection();
    statement = connection.createStatement();
    resultSet = statement.executeQuery(SQL);
    // ...
} finally {
    if (resultSet != null) try { resultSet.close(); } catch (SQLException logOrIgnore) {}
    if (statement != null) try { statement.close(); } catch (SQLException logOrIgnore) {}
    if (connection != null) try { connection.close(); } catch (SQLException logOrIgnore) {}
}

If you don't close them properly as soon as possible, the DB will take it in own hands sooner or later and your application may break sooner or later as you encountered yourself.

如果您不尽快正确关闭它们,DB 迟早会自己掌握它,并且您的应用程序迟早会在您遇到自己时崩溃。

To improve connecting performance, make use of a connection pool --you still need to acquire and close them in the same manner as here above though! It's now just the connection pool implementation which under the hoods worries about actuallyclosing the connection or not.

为了提高连接性能,请使用连接池——您仍然需要以与上面相同的方式获取和关闭它们!现在只是连接池实现,在幕后担心是否实际关闭连接。

回答by Maxym

I seems this can be caused by https://www-304.ibm.com/support/docview.wss?uid=swg1IC63952

我似乎这可能是由https://www-304.ibm.com/support/docview.wss?uid=swg1IC63952引起的

At least for us it is.

至少对我们来说是这样。

Check your db2diag.log for ZRC=0x8005006D=-2147155859=SQLE_CA_BUILT "SQLCA has been built and saved in component specific control block."error messages when you get such disconnections.

ZRC=0x8005006D=-2147155859=SQLE_CA_BUILT "SQLCA has been built and saved in component specific control block."当您遇到此类断开连接时,请检查您的 db2diag.log 以获取错误消息。

Later this week we plan to upgrade to DB2 9.7 FixPack 3a -- will write back if that helped.

本周晚些时候,我们计划升级到 DB2 9.7 FixPack 3a —— 如果有帮助,我们会回信。

回答by ManojM

we also recently faces this issue, and it was due to confusing AND OR clauses along with a and rownum < clause. Putting braces at the right places solved it.

我们最近也面临这个问题,这是由于混淆了 AND OR 子句以及 a 和 rownum < 子句。把牙套放在正确的地方解决了它。