一、问题表象
1.日志显示数据库连接错误(errorCode 17410, state 08000)
2.程序执行异常:数据库初始化失败(init datasource error, url: jdbc:oracle:thin:@IP:1521:orcl java.sql.SQLRecoverableException: No more data to read from socket)
详细日志如下:
2020-05-20 12:51:02
[ERROR]-[Thread: localhost-startStop-1]-[com.alibaba.druid.pool.DruidDataSource.init()]: init datasource error, url: jdbc:oracle:thin:@IP:1521:orcl
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1157)
at oracle.jdbc.driver.T4C8TTIdty.receive(T4C8TTIdty.java:669)
at oracle.jdbc.driver.T4C8TTIdty.doRPC(T4C8TTIdty.java:576)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1166)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1461)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1525)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:734)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1060)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1056)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104)
at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:43)
at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226)
at com.jfinal.core.Config.startPlugins(Config.java:128)
at com.jfinal.core.Config.configPluginWithOrder(Config.java:71)
at com.jfinal.core.Config.configJFinal(Config.java:56)
at com.jfinal.core.JFinal.init(JFinal.java:63)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2020-05-20 12:51:02
[ERROR]-[Thread: localhost-startStop-1]-[com.alibaba.druid.pool.DruidDataSource.init()]: {dataSource-2} init error
java.sql.SQLRecoverableException: No more data to read from socket
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1157)
at oracle.jdbc.driver.T4C8TTIdty.receive(T4C8TTIdty.java:669)
at oracle.jdbc.driver.T4C8TTIdty.doRPC(T4C8TTIdty.java:576)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1166)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1461)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1525)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:734)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1060)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1056)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104)
at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:43)
at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:226)
at com.jfinal.core.Config.startPlugins(Config.java:128)
at com.jfinal.core.Config.configPluginWithOrder(Config.java:71)
at com.jfinal.core.Config.configJFinal(Config.java:56)
at com.jfinal.core.JFinal.init(JFinal.java:63)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5652)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
二、网络环境分析
三、排查误区
1.只要做过网闸映射,不管目标地址是否可用,网闸测试ip和端口都是通的;(容易引导误以为目标地址可用)
2.要尽量保持测试环境与正式环境高度一致,避免引发其他怀疑,误导问题排查;
四、最终结果
就是因为MTU导致数据包被切片,无法正常返回结果(连接异常,无法获取数据)。
MTU:通信术语
最大传输单元(Maximum Transmission Unit)是指一种通信协议的某一层上面所能通过的最大数据包大小(以字节为单位)。
我们在使用互联网时进行的各种网络操作,都是通过一个又一个“数据包”传输来实现的。而MTU指定了网络中可传输数据包的最大尺寸,在我们常用的以太网中,MTU是1500字节。超过此大小的数据包就会将多余的部分拆分再单独传输 。
MTU的设置不是一个值天下通用,所以需要我们合理设置特殊场景的MTU 。
MTU更多信息请参考如下博客: