数据库迁移之后,ETL(数据同步工具)工具连接oracle时,选用jdbc 连oracle数据库的时候出现了ora-12505错误:
错误如下:
数据库 [orcl] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
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:
10.10.88.90:1521:DBDMS
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
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:
10.10.88.90:1521:DBDMS
---------
而直接通过plsql可以正常连接数据库,或者可以通过sqlplus 连接数据库
经过debug和查找相关的资料发现问题原因如下:
jdbc连接数据库的时候,需要使用数据库的sid_name,而不是数据库的services_name
而使用plsql连接数据库的时候,只需要数据库的services_name即可,所以修改连接字符串中的services_name (即连接参数中的database name)为sid_name
附:
查看数据库中当前的sid:
SQL> select INSTANCE_NAME from v$instance;
INSTANCE_NAME
----------------
orcl2