Oracle on the C++ programming

Asked By 10 points N/A Posted on -
qa-featured

I need to know how to use the Oracle language and the C++ Programming or it is even possible to use them together.

SHARE
Answered By 0 points N/A #102544

Oracle on the C++ programming

qa-featured
 
What you need is a header file named DbManager.h. The iostream.h provide library functions for the input and output stream for use.
#include <DbManager.h>
#include <iostream>
using namespace std;
using namespace oracle::occi;
const string sqlStr("select empname from emp");
const string dateFormat("DD-MON-YYYY HH24:MI:SS");
int main()
 
{
    // Initialize Services
    DbManager* dbm = NULL;
    OracleServices* oras = NULL;
    Statement *stmt = NULL;
    ResultSet *result = NULL;
    try
    {
        dbm = new DbManager(<Enter the username>);
        oras = dbm->getOracleServices();
        Connection * conn = oras->connection();
        stmt = conn->createStatement(sqlStr);
        string empname;
        result= stmt->executeQuery();
        while (result->next()){
            empname = result->getString(1);  // get the name
            if (result->isNull(1)){
                cout << "No Employee”;
            }
           cout << empname;
        }
        stmt->closeResultSet(result);
        conn->terminateStatement(stmt);
        delete dbm;
    }
    catch (SQLException& ex)
    {
        if (dbm != NULL)
        {
            dbm->rollbackActions(ex, stmt, result);
       }
    }
    catch (ExoException& ex2)
    {
        cerr << "nGot Exception:n" << ex2.getExceptionText() << endl;
        exit(1);
    }
   
    return 1;
}
 

Related Questions