java jdbc 连接 oracle, 偶尔会出现下面这个错误。
Caused by: java.sql.SQLRecoverableException: IO Error: Connection reset by peer, connect lapse 9 ms., Authentication lapse 0 ms.
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:794)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
... 9 more
Caused by: java.io.IOException: Connection reset by peer, connect lapse 9 ms., Authentication lapse 0 ms.
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:790)
... 17 more
Caused by: java.io.IOException: Connection reset by peer, connect lapse 9 ms.
at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:138)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:317)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1438)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:518)
... 17 more
Caused by: java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at oracle.net.nt.TimeoutSocketChannel.read(TimeoutSocketChannel.java:168)
at oracle.net.ns.NIOHeader.readHeaderBuffer(NIOHeader.java:82)
at oracle.net.ns.NIOPacket.readNIOPacket(NIOPacket.java:252)
at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:118)
报错信息从网上搜索的答案都是 oracle 连接数不够了, 但是写了一个测试程序, 申请的连接数大于 oracle 的最大连接数,无法触发相同的错误, 想请教下如何 100%触发这个报错
1
imzcg2 2022-08-30 14:14:25 +08:00
|
3
imzcg2 2022-08-30 14:40:46 +08:00
https://www.jianshu.com/p/b5dfaffb474d
再试一下吧 alter profile DEFAULT limit idle_time UNLIMITED; connect time |
4
imzcg2 2022-08-30 14:41:36 +08:00
把 UNLIMITED 改成一分钟 idle_time 改成 connect_time,估计很快就炸了(触发)
|
5
imzcg2 2022-08-30 14:44:05 +08:00
time-between-eviction-runs-millis: 5000(5 秒)
如果有要把 5000 改成大于你刚刚设计的时间,不让客户端保活,炸的更快 |
6
scalaer OP |
7
scalaer OP 客户端的逻辑
```java Connection conn = DriverManager.getConnection(xxx); // sleep 70s Thread.sleep(1000 * 70); Statement stmt = conn.createStatement(); ``` |