解決java connection
一、故障現象
環境:CentOS release 6.8 (Final) ,java 1.7 資料庫oracle 11gR2 寫了一個簡單的連線資料庫的JDBC指令碼,連線資料庫,幾十秒後出現connection reset錯誤:
[root@tomcat162 ~]# java -cp /tmp/javaclass/ojdbc14-10.2.0.4.0.jar:/tmp/javaclass/ ConnOracleJdbc
start connection database
java.sql.SQLRecoverableException: IO Error: Connection reset
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)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ConnOracleJdbc.testOracle(ConnOracleJdbc.java:30)
at ConnOracleJdbc.main(ConnOracleJdbc.java:12)
出現這個問題有如下幾個特徵:資料庫負載不高,在其他機器的windows中能迅速連線上,在redhat系統中也能迅速連線上。
二、分析問題:在oracle的alert 日誌出現如下錯誤
Fatal NI connect error 12170.
VERSION INFORMATION:
TNS for Linux: Version 11.2.0.3.0 - Production
Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
Time: 20-SEP-2016 19:25:49
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: TNS:operation timed out
ns secondary err code: 12606
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0
Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=172.16.0.111)(PORT=62302))
WARNING: inbound connection timed out (ORA-3136)
Tue Sep 20 20:23:57 2016
三、進一步分析問題:oracle引數SQLNET.INBOUND_CONNECT_TIMEOUT設定為60秒,可以應付絕大部分情況。這裡情況是在連線時候超出了60秒,所以alert.log列印上面日誌。
四、問題解決:這個問題是java jdk 生成安全隨機數的問題
vim /usr/local/jdk/jre/lib/security/java.security
securerandom.source=file:/dev/urandom
改成:
securerandom.source=file:/dev/./urandom
環境:CentOS release 6.8 (Final) ,java 1.7 資料庫oracle 11gR2 寫了一個簡單的連線資料庫的JDBC指令碼,連線資料庫,幾十秒後出現connection reset錯誤:
[root@tomcat162 ~]# java -cp /tmp/javaclass/ojdbc14-10.2.0.4.0.jar:/tmp/javaclass/ ConnOracleJdbc
start connection database
java.sql.SQLRecoverableException: IO Error: Connection reset
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)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ConnOracleJdbc.testOracle(ConnOracleJdbc.java:30)
at ConnOracleJdbc.main(ConnOracleJdbc.java:12)
出現這個問題有如下幾個特徵:資料庫負載不高,在其他機器的windows中能迅速連線上,在redhat系統中也能迅速連線上。
二、分析問題:在oracle的alert 日誌出現如下錯誤
Fatal NI connect error 12170.
VERSION INFORMATION:
TNS for Linux: Version 11.2.0.3.0 - Production
Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
Time: 20-SEP-2016 19:25:49
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: TNS:operation timed out
ns secondary err code: 12606
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0
Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=172.16.0.111)(PORT=62302))
WARNING: inbound connection timed out (ORA-3136)
Tue Sep 20 20:23:57 2016
三、進一步分析問題:oracle引數SQLNET.INBOUND_CONNECT_TIMEOUT設定為60秒,可以應付絕大部分情況。這裡情況是在連線時候超出了60秒,所以alert.log列印上面日誌。
四、問題解決:這個問題是java jdk 生成安全隨機數的問題
vim /usr/local/jdk/jre/lib/security/java.security
securerandom.source=file:/dev/urandom
改成:
securerandom.source=file:/dev/./urandom
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30393770/viewspace-2125282/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JMETER java.net.SocketException: Connection reset 報錯解決方案JMeterJavaException
- FTP Connection refused error 解決辦法FTPError
- 1 Million TCP Connection 問題解決TCP
- 解決Xmanager-AIX XDMCP Connection failedAI
- Cannot get a connection, pool exhausted解決辦法
- java.net.ConnectException: Connection refused (Connection refused)JavaException
- Mysql host is blocked because of many connection errors;unblock解決方法MySqlBloCError
- FileZilla:425 Can't open data connection for transfer of解決辦法
- go grpc: connection reset by peer 的一種解決方案GoRPC
- scp時候出現ssh Connection refused的解決方案
- 解決org.hibernate.exception.GenericJDBCException: Cannot open connectionExceptionJDBC
- 【轉載】Xlib: connection to ":0.0" refused by server的解決方法Server
- Mysql mysql lost connection to server during query 問題解決方法MySqlServer
- 解決Redis/Codis Connection with master lost(複製超時)問題RedisAST
- ORA-03135: connection lost contact的解決方法
- 解決sphinx connection to 127.0.0.1:9312 failed (errno=0, msg=)127.0.0.1AI
- weblogic連線池重置(Connection reset)問題解決方案Web
- Xlib: connection to ":0.0" refused by server Xlib: No protocol specified解決方案ServerProtocol
- ORA-12537: TNS:connection closed問題解決
- Error establishing a database connection 的解決方法(發現黑客入侵)ErrorDatabase黑客
- 異常解決——GitLab : ssh: connect to host port 22: Connection refusedGitlab
- iOS Xcode, 解決“Could not insert new outlet connection”的問題。iOSXCode
- Connection to https://dl-ssl.google.com refused的解決辦法HTTPGo
- ssh 安裝及登入提示:connection refused的解決辦法
- java.io.IOException: Connection reset by peerJavaException
- 解決 Android studio Connect to 127.0.0.1:[/127.0.0.1] failed: Connection refusedAndroid127.0.0.1AI
- 解決問題-There appears to be trouble with your network connection. Retrying...APP
- JAVA | Java 解決跨域問題Java跨域
- 免密scp解決ssh_exchange_identification:read connection reset by peer 原因IDE
- org.hibernate.exception.JDBCConnectionException: Cannot open connection 解決辦法ExceptionJDBC
- Java亂碼解決方案Java
- java.net.ConnectException: Connection refused 異常JavaException
- java.sql.SQLException: Io 異常: Connection refusedJavaSQLException
- org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection 解決辦法SpringFrameworkJDBCOTGExceptionAI
- Laravel 安裝 sail時ubuntu軟體源很慢或者connection failed 解決辦法LaravelAIUbuntu
- Oracle Universal Connection Pool(UCP) for JDBC 詳解OracleJDBC
- java.lang.OutOfMemoryError: Java heap space的解決JavaError
- Java java.lang.ExceptionInInitializerError 錯誤解決方案JavaExceptionError