Solved

Oracle C++ library

Posted on 2004-09-25
9
986 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 7

Expert Comment

by:BobMc
Comment Utility
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
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 11

Expert Comment

by:mohammadzahid
Comment Utility
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
Comment Utility
Oracle version:9i
C++ environment on Linux platform
client and server (redhat linux 9.0)

0
 
LVL 11

Expert Comment

by:mohammadzahid
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to recover a database from a user managed backup
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now