Solved

Oracle C++ library

Posted on 2004-09-25
9
991 Views
Last Modified: 2013-12-12
hi friends,
              I want to access oracle database through C++ i.e i want to make connection create,delete and access different tables.
              When i installed oracle server on linux i have some demo codes already provided by oracle.
              First these code is not executing because of some library is not present(undefined reference)
               Secondly  Do i require a oracle client to install
               Will you  please give some source codes for oracle connection and accessing database
thanx in advance
0
Comment
Question by:jassy_shah
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 7

Expert Comment

by:BobMc
ID: 12172995
If you want to access an Oracle database, the simplest way is to use the OCCI for C++.
This should be an option when you install the Oracle client.

Typical use is (pulled straight from the Oracle docs)

const string userName = "SCOTT";
const string password = "TIGER";
const string connectString = "";

Environment *env = Environment::createEnvironment();
{
   Connection *conn = env->createConnection(userName, password, connectString);
   Statement *stmt = conn->createStatement("SELECT blobcol FROM mytable");
   ResultSet *rs = stmt->executeQuery();
   rs->next();
   Blob b = rs->getBlob(1);
   cout << "Length of BLOB : " << b.length();
   .
   .
   .
   stmt->closeResultSet(rs);
   conn->terminateStatement(stmt);
   env->terminateConnection(conn);
}
Environment::terminateEnvironment(env);
0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 12174842
Yes, you need atleast Oracle client installed on the system from where you are making connection and have the oci libraries defined on that box.
If oci libraries are not defined then you will get errors at the linking stage. Please refer to Oracle Technology Network site and download Oracle OCI C++ Guide.

0
 

Author Comment

by:jassy_shah
ID: 12206735
Yes i do appreciate ur comments
The programs which i am executing are present on the server itself so i dont think so i require a oracle client installed this is because i already have OCCI library when i install server.
 
        Suppose i install oracle client whether oracle libraries will also be installed with that. Also i am installing client on server itself.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 7

Expert Comment

by:BobMc
ID: 12207280
Yes, you should install a separate client on your server, so you can patch the application interface without affecting your database in the future.

You should get an option to install the libraries with the client  - either via the custom install, or the programme one (cant remember the actual name)
0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 12210211
Please verify the server library path that it contains the correct location of the OCI libraries.

Please provide some more details:

- Oracle database version?
- C++ environment (Example : Visual C++, etc...) ?
- Server operating system?
- Client operating system?


0
 

Author Comment

by:jassy_shah
ID: 12234936
Oracle version:9i
C++ environment on Linux platform
client and server (redhat linux 9.0)

0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 12235008
Does the library path contain correct path where Oracle libraries are located?
On linux what C++ IDE are you using to program, compile and link your program to Oracle database?



0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12511950
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to take different types of Oracle backups using RMAN.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question