在Oracle localhost中连接

时间:2013-10-29 16:07:08

标签: java android oracle

Oracle是IP: ps-server-dom

端口: 1521

Usado o adaptador HOSTNAME para resolver o apelido
Tentativa de contatar (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO
COL=TCP)(HOST=192.168.0.101)(PORT=1521)))
OK (10 ms)

错误:

java.sql.SQLException: Exceção de E/S: The Network Adapter could not establish the connection

代码:

Class.forName("oracle.jdbc.OracleDriver").newInstance();;
    conn = DriverManager.getConnection("jdbc:oracle:thin:@ps-server-dom:1521:PSYS", "psyst", "psyst");

1 个答案:

答案 0 :(得分:0)

检查listener.ora,tnsnames.ora有正确的设置。如果你想用'ps-server-dom'访问它,那么这些文件应该有这个特定的主机名而不是ip地址。

以下显示了oracle xe的这些文件的可能设置。

的tnsnames.ora

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ps-server-dom)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

的listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = ps-server-dom)(PORT = 1521))
    )
  )

注意:如果您在某个域中,则HOST = ps-server-dom.yourdomain.com。 这些文件位于Windows中的“oraclexe\app\oracle\product\<version>\server\network\ADMIN”下。