我已经在我的windows 7 64位操作系统中安装了Oracle 11g Express Edition Release 2,并试图执行JDBC程序,然后我得到了以下错误:

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
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.jlcindia.jdbc.JDBCUtil.geOracleConnection(JDBCUtil.java:28)
    at Lab3O.main(Lab3O.java:15)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:385)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
    ... 8 more

当前回答

我也遇到过同样的问题,通过重新启动OracleServiceXE服务解决了这个问题。转到服务。然后验证“OracleServiceXE”服务是否正常运行

其他回答

I too faced the same issue. I had installed Oracle Express edition 10g in Windows XP OS using VMware and it was working fine. Since it was very awkward typing SQL queries in the SQL utility provided by 10g and since I was used to working with SQL developer, I installed 32 bit SQL developer in XP and tried connecting to my DB SID "XE". But the connection failed with error-ORA-12505 TNS listener doesn't currently know of SID given in connect descriptor. I was at sea as to how this problem occurred since it was working fine with the SQL utility and I had also created few Informatica mappings using the same. I did browse a lot on this stuff hither thither and applied the suggestions offered to me after pinging the status of "lsnrctl" on public forums but to no avail. However, this morning I tried creating a new connection again, and Voila, it worked with no issues. I am guessing after reading in few posts that sometimes listener listens before the DB connects or something(pardon me for my crude reference as I am a newbie here) but I suggest to just restart the machine and check again.

我的甲骨文停止工作,我得到这个错误。我重启了我的机器,也尝试了上述解决方案。最终,我打开了组件服务并重新启动了oracle服务,一切都开始工作了。希望这能帮助到一些人。

我的oracle DB服务器IP最近发生了变化,我在/etc/hosts文件中硬编码了值:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.210.61 myoracledb.mycompanydomain.com myoracledb

必须将192.168.210.61 IP更改为新的IP, lsnrctl停止,然后lsnrctl启动 这些步骤解决了我的问题。

我也遇到过类似的问题。问题开始突然发生-我们有负载平衡的数据库连接URL,但在jdbc连接中,我直接指向一个db。

更改为负载平衡的db url和它的工作。

我也得到了同样的错误,但当他们尝试所有三个失败。 如果以上三点都失败了。尝试LSNRCTL状态,如果您发现服务(在我的情况下是XE)丢失尝试这个

sqlplus /nolog
conn  system
alter system register;  
exit  
lsnrctl status  

现在您可以看到服务 即使没看到也试试这个

sqlplus /nolog  
conn system  
alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' scope = both;  
alter system register;  
exit  
lsnrctl status

这应该可以工作…