The Oracle Invocation interface (Orale call INTERFACE,OCI) is the most comprehensive, performance-efficient Oracle Database interface based on the native "C" language, which provides the full functionality of the Oracle database.
OCI provides the foundation for building various language-specific interfaces, such as Oracle JDBC-OCI, Odp.net, Oracle Precompiled, Oracle ODBC, and Oracle C + + call Interface (OCCI) drivers .
To use C + + operations Oracle database, we often use Oracle C + + call Interface (OCCI) for programming, the following describes how to do OCCI development under Linux.
To do OCCI development under Linux, you must first install a OCCI-related library on the development machine (which contains the libraries needed to develop and the libraries needed to run) and header files, OCCI libraries and headers can be obtained in the following three ways:
(i) Install Oracle Database Engine (2) Install Oracle Client (3) to install Oracle Instant client.
Which, in the first two ways,
The location of the library is generally: /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/Lib
The header file location is generally: /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/rdbms/public/
As long as the Oracle database engine or client is installed, the library and header files can be easily obtained. However, usually our development is to install a database server, and then do development on the client machine, so it is not advisable to install the Oracle Database engine, given the relatively cumbersome installation of Oracle client, we use a third way to reduce a lot of unnecessary work. Nevertheless, it is necessary for us to first briefly introduce how to do OCCI development in the first two ways.
(1) OCCI development mode One
(i) compiling
After the program is written, Makefile defines the relevant variables and compiles them, for example:
Occi_home= /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1
occi_include_dir=$ (occi_home)/rdbms/public/
occi_library_path=$ (occi_home)/Lib
Default
g++ *.cpp-i$ (occi_include_dir)-l$ (occi_library_path)-locci-lclntsh
(ii) operation
After the compilation completes, runs the program, runs the OCCI program must set the following link variable:
Export oracle_base=/sdb1/oracle/11gr2_database_x64
export oracle_home= $ORACLE _base/product/11.2.0.1.0/db_1
Export nls_lang= ' Simplified Chinese ' _china. Zhs16gbk
Export ld_library_path= $ORACLE _home/lib: $LD _library_path
(iii) Additional issues
If you want to copy Occi header files and library files to other machines for OCCI development, follow the steps below, referring to http://blog.csdn.net/zklth/article/details/7184032:
[Plain] View plain Copy (1) method One: Use OCCI related library and header file with Oracle 11.2.0.1 database software . Copy OCCI related header files and library files to directory /opt/OCCI_11g_R2/include and to directories on a machine with oracle 11.2.0.1 r2 databases installed /opt/OCCI_11g_R2/lib , header File: mkdir /opt/occi_11g_r2/include cp -r /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/rdbms/public/* /opt/OCCI_11g_R2/include/ Library file: mkdir /opt/occi_11g_r2/lib cp /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/lib/libclntsh.so.11.1 /opt/OCCI_11g_R2/lib/ cp /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/ lib/libocci.so.11.1 /opt/occi_11g_r2/lib/ cp /sdd1/oracle/11gR2_ database_x64/product/11.2.0.1.0/db_1/libocci11.a /opt/occi_11g_r2/lib/ CP /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/libnnz11.so /opt/occi_11g_r2/lib/ Cp /sdd1/oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/libnnz11.a /opt/occi_ 11g_r2/lib/ cd /opt/occi_11g_r2/lib Create 3 soft links ln -s libocci.so.11.1 libocci.so ln -s libclntsh.so.11.1 libclntsh.so ln -s libclntsh.so libclntsh.so.10.1 [ root@localhost lib]# ll Total 69764 Lrwxrwxrwx 1 root root 17 01-07 13:33 libclntsh.so -> libclntsh.so.11.1 lrwxrwxrwx 1 root root 12 01-07 13:33 libclntsh.so.10.1 -> libclntsh.so -rwxr-xr-x 1 root root 48724689 01-07 12:58 libclntsh.so.11.1 -rw-r--r-- 1 root root 11595642 2012-01-07 libnnz11.a -rw-r--r-- 1 root root 7899997 2012-01-07 libnnz11.so -rw-r--r-- 1 root root 1863334 01-07 12:50 libocci11.a lrwxrwxrwx 1 root root 15 01-07 13:33 libocci.so -> libocci.so.11.1 -rwxr-xr-x 1 root root 1260923 01-07 12:50 libocci.so.11.1 Compile the OCCI program with the following options: occi_home=/opt/occi_11g_r2 occi_include_dir=$ (occi_home)/include OCCI_ library_path=$ (occi_home)/lib g++ *.cpp -i$ (Occi_include_dir) -L$ (OCCI_ Library_path) -locci -lclntsh -lnnz11 # Note to add  LNNZ11,LIBCLntsh.so . compilation succeeded in using the function in the libnnz11.so .
(2) Install ORACLE Instant Client to do OCCI development
(i) Installation of Oracle Instant Client
installation See post http://blog.csdn.net/zklth/article/details/7190035 or http://blog.csdn.net/zklth/article/details/7184032
Contains zip installation and RPM installation. Note that the basic, SDK two packages must be installed for development.
For zip packages.
Development of related header files in:/root/linux-11.2.0.1.0-1.x86_64/instantclient_11_2/sdk/include
Development of related library files in:/root/linux-11.2.0.1.0-1.x86_64/instantclient_11_2.
for RPM packages
Development of related header files in:/usr/include/oracle/11.2/client64
Development of related library files in:/usr/lib/oracle/11.2/client64/lib