Connect OTL to the Oracle database in Linux

Source: Internet
Author: User

Connect OTL to the Oracle database in Linux

# Include <iostream>
Using namespace std;

# Define OTL_ORA10G // indispensable
# Include "otlv4.h" // pay attention to the OTL header file location

Otl_connect db;

Int main ()
{
Otl_connect: otl_initialize ();
Try
{
Db. rlogon ("user/passwd"); // connect to the local database
If (db. connected)
Cout <"Connected to Database" <endl;
}
Catch (otl_exception & p)
{
Cerr <p. msg <endl;
Cerr <p. pai_text <endl;
Cerr <p. sqlstate <endl;
Cerr <p. var_info <endl;
}

Db. logoff ();
Return 0;
}

The above is a very frustrating OTL connection to the Oracle database Code, only the connection without other operations. However, I encountered some problems during compilation: there will be a bunch of error prompts, but there are not many real problems. Details: (PS: My Oracle 10 Gb has been correctly installed locally)

1. first, the system prompts that "oci cannot be found. h ", this file is actually located under $ ORACLE_HOME/rdbms/public. There are many solutions. You can use the"-I "header file path during g ++ compilation, I added the path to the environment variable CPLUS_INCLUDE_PATH.

2. the following error message is displayed when you continue compiling.

Undefined reference to 'oscierverdetach'

Undefined reference to 'ocihandlefree'

This is because the libclntsh. so library file is not connected. This file is located in $ ORACLE_HOME/lib. It is easy to know the cause and solve it. The command is as follows:

G ++ otl_example.cpp-lclntsh-L $ ORACLE_HOME/lib

3. If the compilation is correct, the system prompts "error while loading shared libraries: libclntsh. so.10.1: cannot open shared object file: No such file or directory"

Solution: export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: $ ORACLE_HOME/lib

So far, this applet can run normally. (My ORACLE_HOME:/oracle/product/10.2.0/db_1)

Recommended reading:

OTL-Oracle Development Summary

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

Related Article

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.