java.sql.SQLException: Io 异常: Socket read timed out
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.sql.SQLException: Io 异常: Socket read timed out相关的知识,希望对你有一定的参考价值。
java.sql.SQLException: Io 异常: Socket read timed out
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.doCommit(T4CConnection.java:533)
at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:1119)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.commit(PoolingDataSource.java:211)
at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:139)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:578)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:314)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629)
可能的情况包括:网线没有插好;其他原因导致和数据库服务器的网络断开;连接数据库的URI不正确;数据库没有正确配置;数据库挂了。
总之一点,没有连上数据库。 参考技术A 数据库的请求超时。
可能是要用的表被锁了。追问
不是吧,我查了,木有锁表
参考技术B 将默认超时改长一点追问改了,都改到一分钟了,还是不行
改了,都改到一分钟了,还是不行
参考技术C 代码执行时间过长,超时了追问不会,一天出现78次,不可能是执行时间长了
java.sql.SQLException: Io 异常: NL 异常产生
【中文标题】java.sql.SQLException: Io 异常: NL 异常产生【英文标题】:java.sql.SQLException: Io exception: NL Exception was generated 【发布时间】:2020-01-31 22:53:49 【问题描述】:我正在使用 spark-sql 2.4.1 尝试使用我的 spark 程序连接 oracle 数据库
火花程序
val o_url =//"jdbc:oracle:thin: etc ... it is correct and working
val query ="( SELECT 1 FROM DUAL ) T";
val dfReader = spark.read.format("jdbc")
.option("url", o_url)
.option("driver", "oracle.jdbc.OracleDriver")
.option("user", "ABC")
.option("password", "ZYX")
.option("fetchsize","10000")
val ss = dfReader
.option("inferSchema", true)
.option("schema","LDF")
.option("dbtable", query)
.load();
println(" Table Count : "+ ss.count());
spark.close();
我在我的类路径中添加了“ojdbc14.jar”jar。
我遇到了错误
错误
java.sql.SQLException: Io exception: NL Exception was generated
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at org.apache.spark.sql.execution.datasources.jdbc.DriverWrapper.connect(DriverWrapper.scala:45)
at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:63)
at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:54)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:56)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.<init>(JDBCRelation.scala:115)
at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:52)
at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:340)
at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:239)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:227)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:164)
这里有什么问题?如何解决这个问题?
【问题讨论】:
【参考方案1】:它是与 val o_url =//"jdbc:oracle:thin: etc ...它是正确且有效的
早点
val o_url ="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)... ; ";
我通过删除“;”将其更正如下引号内。
val o_url ="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)... ";
【讨论】:
以上是关于java.sql.SQLException: Io 异常: Socket read timed out的主要内容,如果未能解决你的问题,请参考以下文章
java.sql.SQLException:Io 异常:指定了未知主机
java.sql.SQLException: Io 异常: Socket closed
java.sql.SQLException: Io 异常: Broken pipe 如何在不重启的情况下恢复?
java.sql.SQLException: Io 异常: Socket read timed out
java.sql.SQLException:Io 异常:在与 oracle 的 JDBC 连接期间从读取调用中得到减一
java.sql.SQLException: Io 异常: Got minus one from a read call