Io 異常: The Network Adapter could not establish the connection

  新接觸一個項目,導入源碼,在本地啓動的時候後臺報了一個錯誤:java

Could not discover the dialect to use. java.sql.SQLException: Io 異常: The Network Adapter could not establish the connection
    at java.sql.SQLException: Io 異常: The Network Adapter could not establish the connection
    at     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
    at     at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    at     at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
    at     at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at     at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at     at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at     at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at     at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at     at ch.qos.logback.core.db.DriverManagerConnectionSource.getConnection(DriverManagerConnectionSource.java:54)
    at     at ch.qos.logback.core.db.ConnectionSourceBase.discoverConnnectionProperties(ConnectionSourceBase.java:47)
    at     at ch.qos.logback.core.db.DriverManagerConnectionSource.start(DriverManagerConnectionSource.java:38)
    at     at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:168)
    at     at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:315)
    at     at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:194)
    at     at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:180)
    at     at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:52)
    at     at ch.qos.logback.core.joran.spi.Interpreter.play(Interpreter.java:332)
    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:126)
    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:93)
    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:52)
    at     at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:60)
    at     at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:121)
    at     at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
    at     at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
    at     at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
    at     at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
    at     at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)
    at     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)
    at     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
    at     at org.mule.context.DefaultMuleContextFactory.<clinit>(DefaultMuleContextFactory.java:36)

  首先想到的是是否是數據配置有問題,找到配置數據庫的文件,先檢查服務器IP是否正確,ping一下服務器IP地址,看是否正確,在dos頁面輸入以下指令:sql

ping 服務器IP

  獲得的結果以下:數據庫

    

  請求超時,意識到這多是生產環境的數據,在本地啓動沒有操做權限,須要更改成測試環境的數據庫啓動。apache

 

  如若沒有找到問題所在,後續的分析方法:服務器

    1.判斷端口號是否正確,在通常不會有錯誤,但可能使用多個oracle版本,致使端口號不爲1521的狀況。oracle

     進行一下操做:在DOS上鍵入sqlplus,檢查oracle是否開啓,若一切正常,問題仍沒有解決,進行下一步。app

    2.檢查目標機器是否裝有防火牆,多是服務器端口號屏蔽而形成的,關閉防火牆後,嘗試從新鏈接。仍未解決,進行下一步。測試

    3.檢查數據庫監聽是否啓動:下面以如今主流的數據庫ORACLE爲例:spa

     從新手動啓動數據庫監聽: 開始 → 運行→ 輸入CMD→ 進入DOS命令提示界面 d:>lsnrctl LSNRCTL> status 或者  LSNRCTL> start code

    注:可能服務器上有多個監聽,默認lsnrctl start啓動的是 LISTENER這個監聽, 查看其餘監聽能夠搜索listener.ora這個文件。

     看看是否有其餘的監聽,若是有,使用lsnrctl start 監聽名字。

# listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME=RS)
      (SID_NAME = RS)
      (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)
      (ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.12)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = D:\app\Administrator
相關文章
相關標籤/搜索