Connect MS SQL Server database to Oracle 11g database

血红的双手。 提交于 2019-12-06 07:48:38

问题


I am struggling to create a db link from a Oracle Database to one SQL Server.

For that, I have added the followings:

In file tnsnames.ora:

sqlUserConn =
  (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
      (CONNECT_DATA=(SID=sqlUserConn))
      (HS=OK)
    )

in file listener.ora:

(SID_DESC=
  (SID_NAME=sqlUserConn)
  (ORACLE_HOME=C:\oraclexe\app\oracle\product\11.2.0\server)
  (PROGRAM=dg4odbc)
)

in file sqlnet.ora:

SQLNET.AUTHENTICATION_SERVICES = (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME) 

in file initsqlUserConn.ora:

HS_FDS_CONNECT_INFO = sqlUserConn
HS_FDS_TRACE_LEVEL = OFF

The files tnsnames.ora, sqlnet.ora and listener.ora are placed in **server\network\admin** and initsqlUserConn.ora is placed in **server\hs\admin**

I have the following sql statement:

CREATE DATABASE LINK sqlUserConn CONNECT TO "USER" IDENTIFIED BY "PASSWORD" USING 'sqlUserConn';

And then to test the db link, I am running something similar to:

Select * from table@sqlUserConn

This command is firing the following error:

ORA-12154: TNS:could not resolve the connect identifier specified

Obviously, I have done something wrong.. but still I don't get it.. It should work as I have seen a lot of users doing it like this

Could someone point me to the correct solution for linking a SQL Server database to Oracle 11g?


回答1:


First of all, make sure you are using the correct DSN architecture (32 or 64 bits). It will fire errors if using incorrect architecture. Oracle on Windows has a strange behavior, therefor the command lsnrctl reload or even using lsnrctl stop and then lsnrctl start wont help in refreshing the info placed in the files specified (tnsnames, listener, etc..). So the only solution is to reboot and then check if dblink works.



来源:https://stackoverflow.com/questions/40425521/connect-ms-sql-server-database-to-oracle-11g-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!