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

  新接触一个项目,导入源码,在本地启动的时候后台报了一个错误:

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页面输入如下指令:

ping 服务器IP

  得到的结果如下:

    

  请求超时,意识到这可能是生产环境的数据,在本地启动没有操作权限,需要更改为测试环境的数据库启动。

 

  如若没有找到问题所在,后续的分析方法:

    1.判断端口号是否正确,在一般不会有错误,但可能使用多个oracle版本,导致端口号不为1521的情况。

     进行一下操作:在DOS上键入sqlplus,检查oracle是否开启,若一切正常,问题仍没有解决,进行下一步。

    2.检查目标机器是否装有防火墙,可能是服务器端口号屏蔽而造成的,关闭防火墙后,尝试重新连接。仍未解决,进行下一步。

    3.检查数据库监听是否启动:下面以现在主流的数据库ORACLE为例:

     重新手动启动数据库监听: 开始 → 运行→ 输入CMD→ 进入DOS命令提示界面 d:>lsnrctl LSNRCTL> status 或者  LSNRCTL> start 

    注:可能服务器上有多个监听,默认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
posted @ 2017-08-09 14:56  夜的那种黑丶  阅读(12649)  评论(1编辑  收藏  举报