我在我的 windows 7 64 位操作系统中安装了 Oracle 11g Express Edition Release 2 并尝试执行 JDBC 程序,然后出现以下错误:
I have installed Oracle 11g Express Edition Release 2 in my windows 7 64 bit OS and tried to execute JDBC program, then I got the following error:
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
我通过更正 jdbc 字符串解决了这个问题.
I fixed this issue by correcting my jdbc string.
例如,正确的 jdbc 字符串应该是...
For example, the correct jdbc string should be...
jdbc:oracle:thin:@myserver:1521/XE
但是我使用的 jdbs 字符串是 ...
But the jdbs string I was using is ...
jdbc:oracle:thin:@myserver:1521:XE
(注意:1521
和XE
之间应该是一个/
)
(Note: between 1521
and XE
should be a /
)
这个错误的 jdbc 字符串也会给我一个 ORA-12505 错误.
This bad jdbc string give me a ORA-12505 error too.
这篇关于ORA-12505, TNS:listener 当前不知道连接描述符中给出的 SID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!