日期:2014-05-17  浏览次数:20871 次

求教!数据库连接问题!急!急!
数据库为:oracle 安装在自己笔记本上,笔记本ip:192.168.1.101

Java code
 
异常如下:
 java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
192.168.1.101:1521:devorcl

jdbc文件如下:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.1.101:1521:devorcl
jdbc.username=sjhos
jdbc.password=sjhos

listener.ora 如下:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = g:\oracle\product\10.2.0\db_2)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hp-PC)(PORT = 1521))
    )
  )


tnsnames.ora文件内容如下:

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hp-PC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

external_project =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hp-PC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = devorcl)
    )
  )
DEVORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hp-PC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = devorcl)
    )
  )





------解决方案--------------------
用sqlplus登录下看
------解决方案--------------------
服务启动了吗?
------解决方案--------------------
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = hp-PC)(PORT = 1521))
)
)

hp-PC改为你的iP地址
还有看看是不是防火墙把1521这个端口给封了