Solved

Oracle C++ library

Posted on 2004-09-25
9
989 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
 
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
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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

895 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

13 Experts available now in Live!

Get 1:1 Help Now