Oracle Generic DB Link not working - database

I'm trying to use oracle's hsodbc generic database link driver to access a postgresql database from my oracle 10gr2 database server. I think I have everything configured but I'm receiving this error from the sqlplus promt after trying a remote query.
SQL> select * from temp_user#intranet;
select * from temp_user#intranet
*
ERROR at line 1:
ORA-28545: error diagnosed by Net8 when connecting to an agent
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: preceding 2 lines from INTRANET
If I use "isql" from the linux command line (in other words test just the odbc connection) the query works.
I enter in "isql intranet" (intranet is the name of the odbc connection)
I get the prompt I type select * from temp_user and I receive back my 157 records on screen.
So I know the odbc configuration is setup correctly. Here is what I do for oracle.
%oracle_home/hs/admin/inithsodbc.ora
HS_FDS_CONNECT_INFO = intranet
HS_FDS_TRACE_LEVEL = OFF
HS_FDS_SHAREABLE_NAME = /usr/bin/ODBCConfig
%oracle_home/network/admin/tnsnames.ora
INTRANET =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.1)(PORT = 5432))
)
(CONNECT_DATA =
(SID = INTRANET)
)
(HS = OK)
%oracle_home/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = INTRANET)
(PROGRAM = hsodbc)
(SID_NAME = INTRANET)
(ORACLE_HOME = /home/oracle/app/OraHomeTEST)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracledb.andersen-const.com)(PORT = 5432))
)
)
I have restarted the listener. It's status is as follows.
Services Summary...
Service "INTRANET" has 1 instance(s).
Instance "INTRANET", status UNKNOWN, has 1 handler(s) for this service...
I then go into sqlplus from the database server command line and do the following.
drop database link intranet;
create database link intranet connect to auser identified by apassword using 'intranet';
This is successful.
However when I run
select * from temp_user#intranet
I receive the error
ERROR at line 1:
ORA-28545: error diagnosed by Net8 when connecting to an agent
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: preceding 2 lines from INTRANET
I've spend atleast a good day going back over the configures and trying things and I always get this error.
Anybody have any good ideas,

What does "tnsping intranet" report?
Are you sure your hsodbc prorgram is in the Oracle_home/bin directory of the your gateway installation? Also, is your LD_LIBRARY_PATH set properly?
I believe your LD_LIBRARY_PATH should be $ORACLE_HOME/lib. Sorry, not sure since I don't do much with *Nix these days.

Related

ERROR 12545 : Connect failed because target host or object doesn't exist while trying to connect sqlplus

I want to install oracle instant client but I have been stuck while I was trying to remote DB. I always got error ORA-12545, but my oracle DB is active and works fine.. i already started listener and config /etc/host on both side.
Here's my tnsnames.ora configuration on Oracle Database server:
ROLFSAN =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ullabritta)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rolf)
)
)
and here's my tnsname.ora configuration on oracle instant :
SVEN = -- i give this name as i wish, there's no sven on oracle database
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ullabritta)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rolf)
)
)
did i do something wrong? or there's specific configuration on oracle database server??
Use the IP address, not the hostname. Oracle client uses DNS to resolve the name, and may not use the hosts file.
You can put the connect description in one line and verify
sqlplus user/pass#(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ullabritta)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=rolf)))
Next, make sure your client is picking up the tnsnames.ora file utilizing strace. strace will output all system-calls your client is doing.
strace sqlplus user/pass#TNS_ALIAS
You can place the tnsnames.ora file anywhere you like on the filesystem. The environment variable TNS_ADMIN overrides any default location.
cat > tnsnames.ora <<EOF
MY_ALIAS=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ullabritta)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=rolf)))
EOF
export TNS_ADMIN=./
sqlplus user/pass#MY_ALIAS
Best of luck!

DB Link from oracle -> ms sql ORA-28545 & ORA-02063

We have Oracle 12c – installed on Windows Server 2016 and MS SQL Server 2017 – installed on Windows Server 2019.
When we try to use DB link from Oracle -> MS SQL via SELECT count(*) FROM SMSOUT#TOSIMSQLSERVER we obtain the following error:
ORA-28545: error diagnosed by Net8 when connecting to an agent
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: preceding 2 lines from TOSIMSQLSERVER
28545. 0000 - "error diagnosed by Net8 when connecting to an agent"
*Cause: An attempt to call an external procedure or to issue SQL
to a non-Oracle system on a Heterogeneous Services database link
failed at connection initialization. The error diagnosed
by Net8 NCR software is reported separately.
*Action: Refer to the Net8 NCRO error message. If this isn't clear,
check connection administrative setup in tnsnames.ora
and listener.ora for the service associated with the
Heterogeneous Services database link being used, or with
'extproc_connection_data' for an external procedure call.
Error at Line: 1 Column: 29
The DB Link is created by CREATE DATABASE LINK TOSIMSQLSERVER CONNECT TO "oms" IDENTIFIED BY "…our_pwd…" USING 'simsqlserver';
\hs\admin\initsimsqlserver.ora:
# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC
#
# HS init parameters
#
HS_FDS_CONNECT_INFO = simsqlserver
HS_FDS_TRACE_LEVEL = OFF
\network\admin\listener.ora:
# listener.ora Network Configuration File: C:\app\oracle\product\12.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle\product\12.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\product\12.2.0\dbhome_1\bin\oraclr12.dll")
)
(SID_DESC =
(SID_NAME = simsqlserver)
(ORACLE_HOME = C:\app\oracle\product\12.2.0\dbhome_1)
(PROGRAM = dg4odbc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12.pds.opds.cz)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
\network\admin\tnsnames.ora:
# tnsnames.ora Network Configuration File: C:\app\oracle\product\12.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORACLE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12.pds.opds.cz)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracle.pds.opds.cz)
)
)
LISTENER_ORACLE =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12.pds.opds.cz)(PORT = 1521))
simsqlserver =
(DESCRIPTION =
(ADDRESS=(PROTOCOL=TCP)(HOST=oracle12.pds.opds.cz)(PORT=1521))
(CONNECT_DATA=(SID=simsqlserver))
(HS=OK)
)
\network\admin\sqlnet.ora:
# sqlnet.ora Network Configuration File: C:\app\oracle\product\12.2.0\dbhome_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Can somebody help me find where is the problem ? The SQL ODBC data source test is OK. Also TNSPING to simsqlserver is OK.
EDIT 11.03.2020:
Our Oracle is:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
PL/SQL Release 12.2.0.1.0 - Production
"CORE 12.2.0.1.0 Production"
TNS for 64-bit Windows: Version 12.2.0.1.0 - Production
NLSRTL Version 12.2.0.1.0 - Production
After setting HS_FDS_TRACE_LEVEL = 16 and after lsnrctl stop + lsnrctl start we have the following logs:
\oracle\diag\rdbms\oracle\oracle\trace\alert_oracle.log:
2020-03-11T13:27:40.813789+01:00
HS: Unable to establish RPC connection to HS Agent...
HS: ... Agent SID = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle12.pds.opds.cz)(PORT=1521))(CONNECT_DATA=(SID=simsqlserver))), NCR error = 65535 Unable to retrieve text of NETWORK/NCR message 65535
HS: Unable to establish RPC connection to HS Agent...
HS: ... Agent SID = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle12.pds.opds.cz)(PORT=1521))(CONNECT_DATA=(SID=simsqlserver))), NCR error = 65535 Unable to retrieve text of NETWORK/NCR message 65535
\oracle\diag\rdbms\oracle\oracle\alert\log.xml:
<msg time='2020-03-11T13:27:40.938+01:00' org_id='oracle' comp_id='rdbms'
type='UNKNOWN' level='16' host_id='ORACLE12'
host_addr='::1' module='SQL Developer' pid='2952'>
<txt>HS: Unable to establish RPC connection to HS Agent...
</txt>
</msg>
<msg time='2020-03-11T13:27:40.938+01:00' org_id='oracle' comp_id='rdbms'
type='UNKNOWN' level='16' host_id='ORACLE12'
host_addr='::1' module='SQL Developer' pid='2952'>
<txt>HS: ... Agent SID = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle12.pds.opds.cz)(PORT=1521))(CONNECT_DATA=(SID=simsqlserver))), NCR error = 65535 Unable to retrieve text of NETWORK/NCR message 65535
</txt>
</msg>
Try removing the
SQLNET.AUTHENTICATION_SERVICES= (NTS)
line from sqlnet.ora. That isn't part of the specified configuration for DG4ODBC, per MOS Doc ID 1266571.1.

Cannot access table in oracle after creating dblink

I am trying to create a dblink in oracle but,it is showing me error.
I have a databas orcl1 and I want to connect to another database etlsr which I created next database.
Inside this etlsr database I created a simple table name person inside sys and inserted a data.
Now,i again connect to orcl1 and wanted to connect to etlsr database but it was not happening as I tried
select * from person#ETLSR;
But it throwed me error as:
*
Error at line 1
ORA-02019: connection description for remote database not found
So,i think to create a db link so,I tried :(I tried these from orcl1)
CREATE DATABASE LINK sales
CONNECT TO sys IDENTIFIED BY ashwin
USING 'SALES';
I added in tnsname file as:
SALES =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = SALES_PRD)
)
)
So,when I tried :
select * from person#SALES;
I got error:
ORA-12154: TNS:could not resolve the connect identifier specified
Why is this error coming? Is there any solution for this dblink creation? Can I also access the tables of another database without using dblinks?
Tnsnames.ora
# tnsnames.ora Network Configuration File: E:\oracle\app\AshwinPC\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
TEST=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
sqlnet.ora
# sqlnet.ora Network Configuration File: E:\oracle\app\AshwinPC\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Saying that you have multiple databases on the same computer (and, possibly, some other Oracle software), note that most of them have their own TNSNAMES.ORA file. If you don't pay attention what you're doing, you might be actually using the wrong file. In order to make everything work, you'd have to maintain all those TNSNAMES.ORA files which is a tedious job.
Therefore, create a TNS_ADMIN environment variable which will point to some directory (doesn't even have to be part of the \oracle\ directories but, e.g. c:\my_ora_lib). Put one copy of TNSNAMES.ORA file in there and make sure it contains references to ALL databases you use.
Doing so, you'll make every Oracle software product use exactly this TNSNAMES.ORA file.
As of database link being created "properly" doesn't mean much. You can do it for any non-existent database, but you won't be able to use it:
SQL> create database link dbl_wrong
2 connect to asfasdfj
3 identified by asldfkj234l
4 using 'laskjfoiwe';
Database link created.
SQL> select * from dual#dbl_wrong
2 /
select * from dual#dbl_wrong
*
ERROR at line 1:
ORA-12154: TNS:could not resolve the connect identifier specified
SQL>
Therefore, make sure you used username, password and database that really exist.

How to configure SQL Server database into TNSNAME.ora?

I have created a DB Link into an Oracle Database, pointing to a SQL Server Database.
ODBC if properly configured for this SQL Server Database.
I have also installed Oracle Gateways for SQL Server, on the Oracle Database Server.
When I try to execute this SQL request on my Oracle database :
SELECT * FROM obbud#qualiactst
(qualiactst is my DBLink :
-- PROMPT CREATE DATABASE LINK qualiactst
CREATE DATABASE LINK qualiactst
CONNECT TO iac IDENTIFIED BY ***** USING 'RIATST';
)
the error message is displayed as below :
ORA-12154: TNS : could not resolve the connect identifier specified
I have configured the tnsname.ora file of my Oracle Database Server with this :
RIATST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = grensql2k12R2-1)(PORT = 14539))
)
(CONNECT_DATA = (SID = RIATST))
(HS=OK)
)
(but I don't really know if i have to add a non-oracle database into a tnsname.ora)
I don't understand what i have done wrong, and if some things are missing.
Can you help me ?
Thank you so much
Jeanne
It looks like you don't set up listener onto the target host (grensql2k12R2-1) or don't configure HS initialization file.
Generally, try to follow this guide. There are too many details to check every of it in one answer.
For communication with a heterogeneous MSSQL database. There are two options.
1) Use of specialized Oracle Database Gateway for SQL Server.
Configuring Oracle Database Gateway for SQL Server
2) Oracle Database Gateway for ODBC.
Configuring Oracle Database Gateway for ODBC
Simple example configure Oracle Database Gateway for SQL Server
ORACLE_HOME\dg4msql\admin\initdg4msql.ora
HS_FDS_CONNECT_INFO=host_name:port_name//database_name
ORACLE_HOME\network\admin\listener.ora
SID_LIST_LISTENER=
############# MS SQL ####################
(SID_LIST=
(SID_DESC=
(SID_NAME=dg4msql)
(ORACLE_HOME=oracle_home_directory)
(PROGRAM=dg4msql)
)
)
##########################################
Restart listener
lsnrctl stop
lsnrctl start
ORACLE_HOME\network\admin\tnsnames.ora
connect_descriptor_mssql=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=host_name_oracle_gateway_host)
(PORT=port_number_listener_1521)
)
(CONNECT_DATA=
(SID=dg4msql))
(HS=OK))
SQL> CREATE PUBLIC DATABASE LINK name_dblink CONNECT TO "user" IDENTIFIED BY "password" USING 'connect_descriptor_mssql';
SQL> SELECT * FROM DUAL#dblink;
Example from production server Oracle 11.2.0.4
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dg4msql/admin/inittch7.ora
HS_FDS_CONNECT_INFO=[10.89.250.87]:1433/
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dg4msql/admin/inittch7.ora
HS_FDS_CONNECT_INFO=[10.89.250.88]:1433/
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.89.251.242)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ssps)
(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = ssps)
)
(SID_DESC=
(SID_NAME=tch8)
(ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=dg4msql)
)
(SID_DESC=
(SID_NAME=tch7)
(ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=dg4msql)
)
)
ADR_BASE_LISTENER = /home/oracle/database
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
SSPS_1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.89.251.242)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ssps)
)
)
atch7 =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST= 10.89.251.242)(PORT=1521))
(CONNECT_DATA=(SID=tch7))
(HS=OK)
)
atch8 =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=10.89.251.242)(PORT=1521))
(CONNECT_DATA=(SID=tch8))
(HS=OK)
)
CREATE DATABASE LINK ATCH7.GIFT.KRSK.MPS
CONNECT TO "asuzm_link" IDENTIFIED BY <ENTER USER PASSWORD HERE>
USING 'atch7'
/
CREATE DATABASE LINK ATCH8.GIFT.KRSK.MPS
CONNECT TO "asuzm_link" IDENTIFIED BY <ENTER USER PASSWORD HERE>
USING 'atch8'
/

Connecting Oracle to SQL Server via database link

I am trying to connect from Oracle 10G(on UNIX) to a SQL Server database (On windows). I have looked at the manual and i will admit that i am finding the documentation quite difficult to follow. There seems to be several options to use but none of the documentation describe how each option works.
As an example, i have been given the following information on the database i need to connect to (i.e. the SQL Server database)
Username
Password
Database Name [lets assume the database name is data_extract]
To connect the above i made the following changes
$ORACLE_HOME/hs/admin/inithsodbc.ora
HS_FDS_CONNECT_INFO = data_extract
HS_FDS_TRACE_LEVEL = 0
$ORACLE_HOME/network/admin/tnsnames.ora
sqlserver.db =
(DESCRIPTION =
(ADDRESS = (protocol=tcp)(host=10.10.10.10)(port=49400))
(connect_data = (sid=data_extract))
(hs=ok)
)
$ORACLE_HOME/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = merlin)(PORT = 1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u/app/oracle/product/10.2.0/db)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = db1.mydb.co.uk)
(ORACLE_HOME = /u/app/oracle/product/10.2.0/db)
(SID_NAME = billdb)
)
(SID_DESC =
(SID_NAME = data_extract)
(ORACLE_HOME = /u/app/oracle/product/10.2.0/db)
(program = hsodbc)
)
)
Note: In listener.ora, i only added the last SID_DESC entry.
I then went on and created the database link as shown below
create database link sqlservdb using 'sqlserver.db';
When i try to access a table i get the following error
sqlplus> select * from TESTTABLE#sqlservdb;
select * from TESTTABLE#sqlservdb
*
ERROR at line 1:
ORA-28545: error diagnosed by Net8 when connecting to an agent
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: preceding 2 lines from ORASQLSERVER
A couple of things i am not sure of
Where do i specify the username and password to access the sql server from the oracle db to the sql server db
Having read around on the internet, i can see some people refering to a DSN datasource. I am told that the information that i have is all i need. Is this correct or do i need something else?
The sid i specified in inithsodbc.ora and tnsnames.ora is actually the sql server database. Is this correct?
Any help with the above will be appreciated. Thanks
I used Data Direct drivers which had to be configured on the Oracle UNIX machine. You must create the ODBC connection in UNIX in order to be able to see SQL Server. (At least that has always been how I have done it)
In order to create a database link to SQL Server, you have to enclose your connect name and password between double quotes, like below:
create database link mysqlink
connect to "myuser" identified by "mypassword" using 'servername';

Resources