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

1.确保自己的oracle服务正常运行
2.保证class12.jar,oracle的驱动是否正常加载(放在路径下)
Class.forName ("oracle.jdbc.driver.OracleDriver");//确保该驱动正确加载
Connection conn = DriverManager.getConnection
      ("jdbc:oracle:thin:@ip address:1521:ORA1", "scott", "tiger");
      Statement stmt = conn.createStatement();
      ResultSet rset = stmt.executeQuery (
      "select BANNER from SYS.V_$VERSION"
      );
如果驱动包没有问题,能正常访问

io异常:网络适配器无法建立连接

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)

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)
    )
  )

如果是本来就连接起的,突然出现了这类异常,就将项目重新运行吧!

posted @ 2013-04-23 17:08  全力以赴001  阅读(367)  评论(0编辑  收藏  举报