Configure Unix ODBC to connect to Oracle Databases on Linux

xiaoxiao2021-03-06  41

Configure Unix ODBC to connect to Oracle Databases on Linux

Author: eygle

Source: http://blog.eygle.com

Date: January 05, 2005

Before Oracle10g, Oracle does not provide ODBC drivers under UNIX / Linux, the most extensive unixodbc, unixodbc configuration, but if it is not smooth, it will encounter some problems.

Successfully installed today UnixodBC summarizes the steps for reference. UNIXODBC can be downloaded on the official site.

The following is a test and configuration step:

First you need to install the Oracle client and confirm the network.

1. Test using ISQL

[root @ Magic root] # isql *********************************************************** ***** UnixoDBC - isql ************************************************* ****** SYNTAX ** ** ISQL DSN [UID [PWD]] [options] ** Options ** ** -b Batch. (No prospting etc) ** -dx delimit columns with x ** -x0xxx delimit columns with xx, where ** x is in hex, IE 0x09 is Tab ** -w wrap results in an html table ** -c column name on first row. ** (ONLY USED WHEN -D) ** -mn limit column display width to n ** -v verbose. ** -lx set locale to x ** --Version version ** ** notes ** ** isql supports redirection and piping ** for bath processing. ** ** examples ** ** cat my.sql | isql web myid mypwd -w ** ** Each line in my.sql must contain ** EXACTLY 1 SQL Command Except for the ** Last Line Which Must Be Blank. ** ** please visit; ** ** http://www.unixodbc.org ** pharvey@codebydesign.com ** nick@easysoft.com ********************* ****************************

[root @ Magic root] # isql --versiounixodbc 2.2.10 [root @ Magic root] # Which isql / usr / bin / isql

2./etc/odbc.ini file configuration

[ODBC DATA SOURCES] TEST = Oracle ODBC DRIVER DSN

[Default] driver = /usr/local/easysoft/oracle/libesoracle.so

[TEST] driver = /usr/local/easysoft/oracle/libesoracle.so

Description = Oracleserver = 172.16.1.21 ServerType = OraclePort = 1521User = username Password = passwordDatabase = ava SID = avaMETADATA_ID = 0ENABLE_USER_CATALOG = 1ENABLE_SYNONYMS = 1 [default] Driver = /usr/local/easysoft/oracle/libesoracle.so

3. /etc/odbcinst.ini file configuration

;; odbcinst.ini;

[TEST] Description = odbc for oracledriver = /usr/local/easysoft/oracle/libesoSoSo

[Odbc] trace = 1debug = 1POOLING = NO

4.SQLNET.ORA file configuration

Names.directory_Path = (Tnsnames, onames, hostname)

5.Tnsnames.ora file configuration

AVA =

(Description =

(Address_list =

(Address = (Protocol = TCP) (Host = 172.16.18.21) (port = 1521)))

)

(Connect_data =

(SID = AVA)

)

)

6. Test

[root @ Magic admin] # isql test -v

---------------------------------------

| Connected! |

| | |

| SQL-Statement |

| Help [Tablename] |

| quit |

| | |

---------------------------------------

SQL>

7. Start LDAP

[root @ MAGIC Admin] # / usr / local / libexec / slapd -d 5 -f /Home/eygle/openldap/slapd.conf

@ (#) $ OpenLDAP: SLAPD 2.2.17 (DEC 29 2004 20:45:12) $

Root@magic.hawa.cn: /Home/eygle/openldap/openldap-2.2.17/servers/slapd

Daemon_init:

Daemon_init: Listen on LDAP: ///

Daemon_init: 1 listener to Open ...

LDAP_URL_PARSE_EXT (LDAP: ///)

Daemon: IPv6 Socket () Failed Errno = 97 (Address Family Not Supported by Protocol)

Daemon: Initialized LDAP: ///

Daemon_init: 2 listener Opened

SLAPD INIT: INITIATED Server.

==> backsql_initialize ()

<== BACKSQL_INITIALIZE () >>> DNNORMALIZE:

=> LDAP_BV2DN (CN = Subschema, 0)

LDAP_ERR2STRING

<= ldap_bv2dn (cn = subschema) = 0 access

=> LDAP_DN2BV (272)

LDAP_ERR2STRING

....

==> BACKSQL_OPEN_DB_CONN ()

BACKSQL_OPEN_DB_CONN (): Connected, Adding to Tree

<== BACKSQL_OPEN_DB_CONN ()

BACKSQL_GET_DB_CONN (): First Call - Reading Schema Map

==> BACKSQL_LOAD_SCHEMA_MAP ()

LDAPINFO.DN_RU FIELD EXISTS in The Schema

BACKSQL_LOAD_SCHEMA_MAP (): at_query "SELECT NAME, SEL_EXPR, from_TBLS, JOIN_WHERE, ADD_PROC, DELETE_PROC, PARAM_ORDER,

EXPECT_RETURN, SEL_EXPR_U from LDAP_ATTR_MAPPINGS WHERE OC_MAP_ID =? "

<== BACKSQL_LOAD_SCHEMA_MAP ()

<== BACKSQL_GET_DB_CONN ()

==> BACKSQL_FREE_DB_CONN ()

BACKSQL_FREE_DB_CONN (): Closing DB Connection

==> BACKSQL_CLOSE_DB_CONN ()

<== BACKSQL_CLOSE_DB_CONN ()

<== BACKSQL_FREE_DB_CONN ()

<== BACKSQL_DB_Open (): Test succeeded, Schema map loading

SLAPD Starting

Started successfully.