java.sql.SQLException: Io 異常: Connection refused
客戶提供了配置好的RAC資料庫服務,要求我們切換到該環境下使用。如是,我就修改了jdbc連線的URL配置資訊,改為如下:
url=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.12)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.13)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = ON)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ZZD)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RETIRES = 20)(DELAY = 15))))
其他保持不變,啟動應用伺服器,結果日誌狂拋錯:
java.sql.SQLException: Io 異常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870336)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:361)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:442)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
java.sql.SQLException: Io 異常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870336)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:361)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:442)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
at oracle.jdbc.driver.OracleConnection.
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:442)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
java.sql.SQLException: Io 異常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870336)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
at oracle.jdbc.driver.OracleConnection.
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:442)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
如是,修改URL,改為連線RAC裡面的單機加例項名,2臺都可以連線成功。改為單機加服務名ZZD,一樣的報錯。客戶端配置ZZD,透過sqlplus連線正常,排除RAC配置問題。
想盡各種辦法,也沒找到原因,進入應用程式的lib目錄,找到oracle的jdbc驅動jar,居然有classes12.jar和ojdbc14.jar兩個版本的驅動,如是刪除classes12.jar,再次啟動應用伺服器,報下面的錯誤
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
192.168.1.13:1521:ZZD
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
192.168.1.13:1521:ZZD
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:439)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.
at oracle.jdbc.driver.T4CConnection.
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
然後,我把URL切換為最上面的叢集配置方式,再次啟動應用,一切正常了。
看來影響jdbc連線的根源,還是jdbc驅動的版本了,不同的版本,對叢集的支援不一樣,害得我折騰了好久。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-744251/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- java.net.ConnectException: Connection refused 異常JavaException
- nacos Connection refused (Connection refused)
- Linux啟動tomcat後執行shutdown.sh關閉時出現異常:Connection refused (Connection refused)LinuxTomcat
- 異常解決——GitLab : ssh: connect to host port 22: Connection refusedGitlab
- java.net.ConnectException: Connection refused (Connection refused)JavaException
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error
- 異常與IO
- go get報錯connect: connection refusedGo
- SSH出現Connection refused錯誤
- java.sql.SQLException: No value specified for parameter 1 異常分析JavaSQLException
- ssh: connect to host localhost port 22: Connection refusedlocalhost
- raw.githubusercontent.com port 443: Connection refusedGithub
- Error!: SQLSTATE[HY000] [2002] Connection refusedErrorSQL
- nameko shell 報錯 : [Errno 111] Connection refused
- telnet localhost 44444 telnet: connect to address ::1: Connection refusedlocalhost
- kubernetes應用flannel失敗 Connection refused.
- HttpClient遭遇Connection Reset異常,如何正確配置?HTTPclient
- MySQL異常刨析:ata source rejected establishment of connection, message from server: “Too many connectionMySqlServer
- Java中處理SocketException: Connection reset”異常的方法JavaException
- OGG-01224 error 111:Connection refused - retries exceeded.Error
- 解決 Android studio Connect to 127.0.0.1:[/127.0.0.1] failed: Connection refusedAndroid127.0.0.1AI
- Listener refused the connection with the following error:ORA-12514, TNS:listenerError
- Solaris SSH 服務處於maintenance模式,ssh connection refusedAINaN模式
- 坑:ssh: connect to host github.com port 22: Connection refusedGithub
- The connection to the server 10.10.0.2:6443 was refused - did you specify the right host or port?Server
- Idea資料庫引入異常:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognizedIdea資料庫JavaSQLExceptionServerZed
- Jedis 連線 Redis報JedisConnectionException: java.net.ConnectException: Connection refusedRedisExceptionJava
- java.sql.SQLException:IO 錯誤:Socket read timed out !JavaSQLException
- (20200916 Solved)Docker||redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refusedDockerRedis127.0.0.1
- 連線資料庫提示sqlstate[hy000] [2002] Connection refused資料庫SQL
- Java程式設計基礎20——異常&IO(File類)Java程式設計
- ORACLE TNS Io異常End of TNS data channel&ORA-12518Oracle
- idea報錯資料庫connection refused【杭州多測師_樹哥】Idea資料庫
- 解決telnet: connect to address 127.0.0.1: Connection refused的錯誤資訊問題127.0.0.1
- CM agent 傳送heartbeat給CM server 不斷髮生 connection refused:timed outServer
- Sqoop從Oracle抽數錯:IO Error: Connection resetOOPOracleError
- 異常和異常呼叫鏈
- 異常篇——異常記錄
- 異常篇——異常處理