Posted by Karun Dutt on Mar 26, 2008
I recently imported the contents of an Oracle 8i database into an 11g database. Since the original application needed to query a MS SQL Server database, I had to set up generic connectivity, which among other things, allows , the Oracle database to connect to non-Oracle databases for DML operations. The external database is referred to via a database link. In Oracle 11g, the Database Generic Connectivity for ODBC (dg4odbc) is a replacement for hsodbc.
After following the instructions for a typical setup shown here: Configuring Oracle Database gateway for ODBC, I set up a database link to a remote SQL Server database, and called it SQLSERVER. I planned to use the following query to test whether it is working:
SQL> select * from information_schema.tables@SQLSERVER;
-- gives me a list of tables that this connection has access to
Since I had installed 11g on a 64-bit Linux system, I downloaded and installed the 64-bit DataDirect drivers (seems logical). I could connect to the SQL Server database using the demoodbc executable. So everything looked good until I ran the test:
SQL> select * from information_schema.tables@SQLSERVER;
select * from information_schema.tables@SQLSERVER
*
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 SQLSERVER
SQL>
I did enable tracing, but there is no odbc trace yet to look at, and no log either under $ORACLE_HOME/hs/log Interestingly, the only clue I get (from the listener trace) is:
Mon Mar 25 12:59:54 2008
24-MAR-2008 12:59:54 * (CONNECT_DATA=(SID=odbc_SQLSERVER)(CID=(PROGRAM=)(HOST=myhost)(USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.121)(PORT=43917)) * establish * odbc_SQLSERVER * 12518
TNS-12518: TNS:listener could not hand off client connection
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 32: Broken pipe
Mon Mar 25 13:02:50 2008
In plain English, the listener is trying to tell me that it is unable to handle the processing expected with dg4odbc. The seed of doubt is sown: does dg4odbc work? Now would be a good time to check it out:
[oracle@myhost ~]$ dg4odbc
dg4odbc: error while loading shared libraries: libagtsh.so: cannot open shared object file: No such file or directory
[oracle@myhost ~]$
Arrggh! dg4odbc is a 32-bit Application — even when installed on 64-bit Linux. For this application to run on 64-bit Linux, I have to ensure that LD_LIBRARY_PATH is set appropriately, that the 32-bit libraries are read before the 64-bit libraries.
[oracle@myhost ~]$ echo $LD_LIBRARY_PATH
/d01/oracle/product/11.1/lib32:/d01/oracle/product/11.1/lib:/lib:/usr/lib
[oracle@myhost ~]$
And:
[oracle@myhost ~]$ dg4odbc
Oracle Corporation --- TUESDAY MAR 25 2008 15:26:11.565
Heterogeneous Agent Release 11.1.0.6.0 - Production Built with
Oracle Database Gateway for ODBC
[oracle@myhost ~]$
So that means I can alter the entries in listener.ora to also use the libraries appropriately. Here’s the old listener.ora:
(SID_DESC =
(SID_NAME = odbc_sqlserver)
(ORACLE_HOME = /d01/oracle/product/11.1)
(PROGRAM = dg4odbc)
(ENVS=LD_LIBRARY_PATH=/d01/oracle/odbc64v53/lib:
/d01/oracle/product/11.1/lib)
)
And the new listener.ora:
(SID_DESC =
(SID_NAME = odbc_sqlserver)
(ORACLE_HOME = /d01/oracle/product/11.1)
(PROGRAM = dg4odbc)
(ENVS=LD_LIBRARY_PATH=/d01/oracle/odbc64v53/lib:/d01/oracle/product/11.1/lib32:/d01/oracle/product/11.1/lib)
)
Still no joy! Read the rest of this entry . . .