oracle连接

使用字符串“jdbc:oracle:thin:@127.0.0.1:1521:orcl”连接数据库时,抛出异常:
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:
127.0.0.1:1521:orcl

解决方法:
将listener.ora 文件中的内容
# listener.ora Network Configuration File: /app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /app/oracle/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = suse10.site)(PORT = 1521))
    )
  )

修改为:
# listener.ora Network Configuration File: /app/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /app/oracle/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = /app/oracle/oracle/product/10.2.0/db_1)
      (SID_NAME = ORCL)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = suse10.site)(PORT = 1521))
    )
  )


上述改动在第11行上添加了如下内容:
(SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = /app/oracle/oracle/product/10.2.0/db_1)
      (SID_NAME = ORCL)
    )


最后,通过 控制面板-->管理工具-->服务-->OracleOraDb10g_home1TNSListener 重新启动oracle监听服务!!!


你可能感兴趣的:(oracle,sql,jdbc)