`

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

 
阅读更多
Io 异常: The Network Adapter could not establish the connection
异常如下:

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: The Network Adapter could not establish the connection)
  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
Caused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
  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)


主要原因:

1.可能是server.xml文件的DataSource配置出错。

(1).如果用到的是本机上的数据,本地数据源里的部分配置为: username="pcisv62" password="11" url="jdbc:oracle:thin:@localhost:1521:orcl"
(2).如果用到的是服务器上的数据,则数据源里的部分配置为: username="pcisv62" password="11" url="jdbc:oracle:thin:@dbserver:1521:corev6"

(dbserver为服务器的名字,corev6为服务器上Oracle的SID)
(3).是否导入架包class12.jar

2.可能是oracle的tnsnames.ora文件配置出错。

oracle的安装目录E:\oracle\ora92\network\admin下的tnsnames.ora:
本地配置:
ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 主机名)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL)
    )
  )
或服务器配置:
COREV6_DBSERVER =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dbserver)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = COREV6)
      (SERVER = DEDICATED)
    )
  )
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics