Ask the Expert

How does database connectivity work in C++?

How does database connectivity work in C++?

    Requires Free Membership to View

You'll want to use one of two methods: Pro*C or OCI for C++. Both are Oracle products and are installed with your database software. Pro*C is the easiest of the two to use, but OCI has all of the power. With Pro*C, you place SQL statements in your C++ code. You also place the simple statements to make a database connection and disconnection in your C++ code. Before you compile the C++ code, you run your source program through a precompiler. This precompiler essentially takes your simple database lines of code in your C++ source code and expands it into everything that is needed to perform that statement. You then run your precompiled code through your C++ compiler.

I would highly recommend reading the Pro*C/C++ Precompiler Programmer's Guide. It contains sample code to help you along the way. You can find a copy of that doc here:

http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a97269/toc.htm

This was first published in October 2004

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.