ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

Feb 2, 2020 阅读(76)

标签: Oracle

升级数据库后突然就连接不上,错误信息如下:    

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.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
	at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:197)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:525)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413)
	at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)
	at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:187)


问题根源是不同版本数据库 Url 的写法有所不同,修改成当前数据库正确的写法即可:

老格式:
    jdbc:oracle:thin:@192.168.1.110:1521:ORCL


新格式:
    jdbc:oracle:thin:@192.168.1.110:1521/ORCL


MongoDB学习园