oracle linux服务器中的“java.sql.SQLException:I/O错误:连接重置”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43777075/
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
"java.sql.SQLException: I/O Error: Connection reset" in linux server
提问by Mohamed Fenni
I have a java program which connect to oracle database sometimes it work and sometimes show me this error message :
我有一个连接到 oracle 数据库的 java 程序,有时它会工作,有时会显示此错误消息:
Exception in thread "main" java.sql.SQLRecoverableException: IO Error: Connection reset
线程“main”中的异常 java.sql.SQLRecoverableException:IO 错误:连接重置
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:498)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
How i can solve this problem?
我该如何解决这个问题?
回答by Karim
Answer took from oracle forum, here:
答案来自 oracle 论坛,这里:
java.security.SecureRandom
is a standard API provided by sun. Among various methods offered by this class void nextBytes(byte[])
.
java.security.SecureRandom
是sun提供的标准API。在这个类提供的各种方法中void nextBytes(byte[])
。
This method is used for generating random bytes. Oracle 11g JDBC drivers use this API to generate random number during
login. Users using Linux have been encountering SQLException("Io exception: Connection reset")
.
此方法用于生成随机字节。Oracle 11g JDBC 驱动程序使用此 API 在登录期间生成随机数。使用 Linux 的用户一直遇到SQLException("Io exception: Connection reset")
.
The problem is two fold:
问题有两个方面:
The JVM tries to list all the files in the /tmp (or alternate tmp directory set by -Djava.io.tmpdir) when
SecureRandom.nextBytes(byte[])
is invoked. If the number of files is large the method takes a long time to respond and hence cause the server to timeoutThe method
void nextBytes(byte[])
uses /dev/random on Linux and on some machines which lack the random number generating hardware the operation slows down to the extent of bringing the whole login process to a halt. Ultimately the the user encounters SQLException("Io exception: Connection reset")
JVM 尝试在
SecureRandom.nextBytes(byte[])
调用时列出 /tmp(或由 -Djava.io.tmpdir 设置的备用 tmp 目录)中的所有文件 。如果文件数量很大,该方法需要很长时间才能响应,从而导致服务器超时该方法
void nextBytes(byte[])
在 Linux 和一些缺少随机数生成硬件的机器上使用 /dev/random 操作减慢到使整个登录过程停止的程度。最终用户遇到 SQLException("Io exception: Connection reset")
Users upgrading to 11g can encounter this issue if the underlying OS is Linux which is running on a faulty hardware.
如果底层操作系统是在故障硬件上运行的 Linux,升级到 11g 的用户可能会遇到此问题。
The cause of this has not yet been determined exactly. It could either be a problem in the hardware or the fact
that for some reason the software cannot read from dev/random
造成这种情况的原因尚未确切确定。可能是硬件有问题,也可能是由于某种原因软件无法读取dev/random
a solutionseems to add this setting to the jvm
一个解决方案似乎将此设置添加到 jvm
-Djava.security.egd=file:/dev/./urandom
回答by Renier
Connection reset usually happens when the connection between you app and the database gets disconnected for example network issue or resources that's required.
连接重置通常发生在您的应用程序和数据库之间的连接断开时,例如网络问题或所需的资源。
Check the following post it should give you an idea of what to check. SQLRecoverableException: I/O Exception: Connection reset
检查以下帖子它应该让您了解要检查的内容。 SQLRecoverableException:I/O 异常:连接重置