How to Setup and Run Oracle10g ODBC Driver on Solaris

作者: Maclean Liu , post on September 29th, 2009 , English Version
【本站文章除注明转载外,均为本站原创编译】
转载请注明:文章转载自: Oracle Clinic – Maclean Liu的个人技术博客 [http://www.oracledatabase12g.com/]
本文标题: How to Setup and Run Oracle10g ODBC Driver on Solaris
本文永久地址: http://www.oracledatabase12g.com/archives/how-to-setup-and-run-oracle10g-odbc-driver-on-solaris.html
Applies to:
Oracle ODBC Driver - Version: 10.2.0.1.0 to 11.2.0.1 - Release: to 11.2
Oracle Solaris on SPARC (64-bit)
Sun Solaris SPARC (64-bit)
Goal
How to Setup and Verify Setup of Oracle ODBC Driver on Solaris, and especially ODBC Driver Manager ?
Solution
The Oracle ODBC Driver need to be installed into a Oracle Home (ORACLE_HOME) either from the Oracle Database Software Media or the Client Software.  Some steps are needed to be handled as a Operating System supervisor (root).

Download, setup and install unixODBC

To be able to use the Oracle ODBC Driver a ODBC Driver Manager need to be installed.

It could be downloaded and installed from www.unixodbc.org

unixODBC is currently availible in a gzip, tar format.

   1. Ensure that you are logged in as root user

   2. Copy the unixODBC*.tar.gz file somewhere you can create files and directories

      cp unixODBC*.tar.gz /tmp

   3. Extract

      cd /tmp
      gunzip unixODBC*.tar.gz
      tar xvf unixODBC*.tar

   4. change to the extracted directory unixODBCxxxx directory with all source files inside.

      cd unixODBCxxxx

   5. Ensure that a certified and supported C/C++ Compiler is installed - see Note:43208.1
      You can check an installed copiler by using Note:549826.1

      A Sun Studio could be download for free at Sun Developer Network

   6. Following steps switch from GCC to the supported SUN ONE / Forte / Workshop compilers.

          * Please check PATH so that Compiler can be found - to check if compiler can be found, just use "cc -V"

            CC=cc
            export CC

          * When 64-bit ODBC (recommended) should be used, following steps have to be done, too

            CFLAGS="-xarch=v9 -xchip=ultra3 -xO3 -Xa -xstrconst -dalign -xF"
            LDFLAGS="-xarch=v9"
            ac_cv_sizeof_long=8
            export LDFLAGS CFLAGS ac_cv_sizeof_long

          * Default DM_HOME is /usr/local. To change it to /usr/local/unixODBC do:

            ./configure --prefix=/usr/local/unixODBC --enable-gui=no

          * To be conform with the GNU guidelines the odbcinst file is now installed by default in {prefix}/etc, this can be altered using the --sysconfdir option to configure. To install the files in the old default /etc you would run configure like this:

            ./configure --sysconfdir=/etc 

          * To install Driver Manager do:

            make
            make install

Verify the installation of ODBC Driver Manager

   1. To display DM_HOME

      odbc_config --prefix

      Default output:
      /usr/local

   2. To show the System Config File:

      odbc_config --odbcinstini

      Default output:
      /usr/local/etc/odbcinst.ini

   3. To Display System Data Source File:

      odbc_config --odbcini

      Default output:
      /usr/local/etc/odbc.ini

Setup the Oracle ODBC Driver:

There are two different ways of setting up the Oracle ODBC Driver..

   1. Using odbcinst utility

          * Create a driver template, in this case we name it ODBCDriverTemplate
            The example content of ODBCDriverTemplate look like (replace $ORACLE_HOME with an absolute PATH):

            [ODBC]
            Trace = No
            TraceFile = /tmp/sql.log
            ForceTrace = No
            Pooling = No

            [Oracle_ODBC_Driver_in_ora102]
            Description = Oracle 10g R2 ODBC driver.
            Driver = $ORACLE_HOME/lib/libsqora.so.10.1
            Setup =
            FileUsage =
            CPTimeout =
            CPReuse =

          * Replace "Oracle_ODBC_Driver_in_ora102", Description, Driver with your own specific data.

          * To install the driver into odbcinst.ini (need to be run as root):

            odbcinst -i -d -f ODBCDriverTemplate

   2. Manually

      Add the content of ODBCDriverTemplate into

      $DM_HOME/etc/odbcinst.ini

      (or sysconfdir/odbcinst.ini if that is specified during Driver Manager installation)

Setup the Data Source Name (DSN):

There are two different ways of setting up the Data Source Name.

   1. Using odbcinst utility

      Execute

      odbcinst

   2. Edit the odbc.ini (System DSN) and/or .odbc.ini (User DSN) file manually

          * Create a DSN template, in this case we name it ora102Template.
            The example content of ora102Template look like:

            [ora102]
            Application Attributes = T
            Attributes = W
            BatchAutocommitMode = IfAllSuccessful
            CloseCursor = T
            DisableDPM = F
            DisableMTS = T
            Driver = Oracle_ODBC_Driver_in_ora102
            DSN = ora102
            EXECSchemaOpt =
            EXECSyntax = T
            Failover = T
            FailoverDelay = 10
            FailoverRetryCount = 10
            FetchBufferSize = 64000
            ForceWCHAR = F
            Lobs = T
            Longs = T
            MetadataIdDefault = F
            QueryTimeout = T
            ResultSets = T
            ServerName = ora102
            SQLGetData extensions = F
            Translation DLL =
            Translation Option = 0
            UserID = scott

            The Driver in DSN need to map to the Driver name "Oracle_ODBC_Driver_in_ora102" in odbcinst.ini.
            ServerName is the Database Servicename.

          * To add the DSN into the User DSN (default)

            odbcinst -i -s -f ora102Template

            This will add an entry to

            $HOME/.odbc.ini

            this should always be done as the user that are executing the ODBC application.

          * To remove the User DSN

            odbcinst -u -s -n ora102

          * To add a System DSN

            odbcinst -i -l -s -f ora102Template

            This will add an entry to

            $DM_HOME/etc/odbc.ini

            (or sysconfdir/odbc.ini if that is specified during Driver Manager installation), this should always be done as root.

Test setup of Driver and DSN

There are a number of ways to do that:

   1. Use the connect demo sample

          * Goto demo directory and set library path

            cd $ORACLE_HOME/odbc/demo/cdemo
            LD_LIBRARY_PATH=$ORACLE_HOME/lib:$DM_HOME/lib
            export LD_LIBRARY_PATH

          * edit

            $ORACLE_HOME/odbc/demo/cdemo/connect.c

            and change

            retcode = SQLConnect(hdbc, "TestDBDSN", SQL_NTS, "SCOTT", SQL_NTS, "tiger",                      SQL_NTS);

            so that DSN, username and password match your credentials - for example change "TestDBDSN" to "ora102"

          * Build connect.c by doing

            make -f cdemo_odbc.mk connect

          * Execute

            ./connect

            which should bring back something like:

            Current DBMS version is 10.02.0030

      When using Client 10.2.0.2 and lower you may hit Bug:6036962 / Bug:4551135 preventing from building  and you should consider to upgrade to 10.2.0.3 or higher

   2. Use isql / iusql utility

      iusql ora102 SCOTT tiger

      and performing

      select sysdate from dual

      should bring back

      +--------------------+
      | SYSDATE            |
      +--------------------+
      | 2006-12-18 16:13:00|
      +--------------------+
      SQLRowCount returns -1
      1 rows fetched

   3. Use your own ODBC Application

© 2009 – 2010, www.oracledatabase12g.com. 版权所有.文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.

相关文章 | Related posts:

  1. Configuring Linux for the Oracle 10g VIP or private interconnect using bonding driver
  2. How to setup Streams replication using DBMS_STREAMS_ADM.MAINTAIN_* set of procedures
  3. 9i Best Practices For Streams RAC Setup
  4. Rolling Cursor Invalidations with DBMS_STATS in Oracle10g
  5. Linux Ethernet Bonding Driver
  6. Oracle10g: Using SQLAccess Advisor (DBMS_ADVISOR) with the Automatic Workload Repository
  7. Oracle database 11g r2最新安装体验
  8. oracleasm failed to createdisk on raw device
  9. "hcheck.sql" script to check for known problems in Oracle8i, Oracle9i, Oracle10g and Oracle 11g

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>