Use OCCI or OCI to connect to the Oracle database in Linux

Source: Internet
Author: User
Tags file url
First, go to the Oracle official website to download the C language library file and header file URL as follows, select the corresponding InstantClient version (I downloaded all zip packages, no rpm package downloaded, rpm

First, go to the Oracle official website to download the C language library file and header file URL as follows, select the corresponding Instant Client Version (I downloaded all zip packages, no rpm package downloaded, rpm

FirstGo to the Oracle official website to download the C language library file and header file URL as follows, select the corresponding Instant Client Version (I downloaded all zip packages without downloading the rpm package, the rpm package should be configured during installation ):(I personally suggest you zip the package and try it yourself to improve your understanding.)

The following is the version of linux i386

Instant Client Package-Basic contains the dynamic library file libclntsh. so.11.1 (the latest version may be different) and loads it to the dynamic library search path.(Specific operation of sudo mv *. so/usr/bin).
* The Instant Client Package-SDK contains the header file.
* Instant Client Package-SQL * Plus sqlplus is better to be installed next. test whether the Client is configured and check whether all SQL statement execution results require it.

The following are my three:

Instantclient-basic-linux32-11.2.0.2.0.zip

Instantclient-sdk-linux32-11.2.0.2.0.zip

Instantclient-sqlplus-linux32-11.2.0.2.0.zip

Download file path settings:
/Home/oracle/lib stores various library files of Basic and sqlplus, so in/etc/ld. so. add the path/home/oracle/lib to the conf file, and the path is libclntsh in the current file. so.11.1 create a soft connection ln-s libclntsh in the library file. so.11.1 libclntsh. so allows the code to find the library file when connecting to the dynamic library. (In fact, there are a lot of. so files, all of which are dynamic libraries. They must be placed in the dynamic library like libclntsh. so.11.1 to find the library files.)

Run ldconfig
/Home/oracle/include stores the SDK header file.

# Tnsnames. ora Network Configuration File:/home/oracle/product/10.2.0/db_1/network/admin/tnsnames. ora
TEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.8) (PORT = 1521 ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1 ))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)


After the preceding settings are configured, log out of the user and log on again to make the ORACLE_HOME environment variable take effect. The check method is very simple. Run the following commands on the terminal:
[@ Localhost ~] $ Echo $ ORACLE_HOME
/Home/oracle
If there is a path output as above, the configuration is successful. If there is no output, edit it again ~ /. Bashrc to see what went wrong.


After the check is complete, run sqlplus to log on to the database! The example is as follows. The C program is successfully connected to the database! Finally, the environment has been configured.

In fact, there is still a problem at this time (it is estimated that I haven't updated it for a long time, it may be a problem), that is. /sqlplus: error while loading shared libraries: libaio. so.1: cannot open shared object file: No such file or directory

Remedy: sudo apt-get install libaio1

Connection time: sqlplus test/test@192.168.17.151/test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.