oraclejdbc连接数据库的问题ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

时间:2024-03-31 18:22:34

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:478)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:547)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:225)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:29)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:556)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at com.forward.jdbc.TestJDBC.main(TestJDBC.java:27)
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:448)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1577)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:353)
... 7 more

一、正确的链接字符串

"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1521))(CONNECT_DATA=(SID=ORACLE)));User Id=system;Password=sa;"

--HOST=服务器IP地址, 如192.16.1.100

--SID= .Net Configuration Assistance-->本地Net服务器名配置-->添加-->服务名(即为该服务名,并非pl/sql登陆时的DataBase属性值)

--User Id=用户名, 如User Id=system

--Password=登录密码,如Password=sa

主要是服务名那里填错了

查看服务名在这

oraclejdbc连接数据库的问题ORA-12505, TNS:listener does not currently know of SID given in connect descriptor