Yeah, I've never heard of that DbManager thing. I can give you a sample of something I worked on as a test program, just something to make sure I could connect to a database and actually read data from one of the tables. Things in blue are bits of code that I've changed to protect anything potentially sensitive (user names/service names,table names).
I've highlighted the key database related stuff in green.
Code:
#include <occi.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;
using namespace oracle::occi;
#ifndef _DEBUG
#pragma comment(lib,"oraocci10.lib")
#else
#pragma comment(lib,"oraocci10d.lib")
#endif
int main()
{
Environment * env = Environment::createEnvironment();
Connection * conn = NULL;
const string strUser = "YOUR_USER_HERE"; // User we connect as
const string strConn = "YOUR_CONNECTION_HERE"; // Database connection
string strPass; // Password for above
// Make sure we get a connection to the database in question, otherwise quit.
try
{
cout << "Enter password for user YOUR_USER_HERE: ";
cin >> strPass;
conn = env->createConnection(strUser,strPass,strConn);
}
catch (SQLException &sqlExcp)
{
cerr << sqlExcp.getErrorCode() << ": " << sqlExcp.getMessage()
<< "Press a key to continue..." << endl;
cin.ignore(); // Ignore previous ws
cin.get();
Environment::terminateEnvironment(env);
return EXIT_FAILURE;
}
// We should have a connection so we are connected to the database.
if( conn )
{
cout << "Connected to the Oracle Database Server" << endl;
// Create the SQL statement we are going to be executing.
Statement * stmt = NULL;
stmt = conn->createStatement("SELECT ser, frq, xla, xlg FROM TABLE_NAME "
"WHERE ser LIKE 'FAA 07%'");
if( stmt )
{
// Execute the SQL statement and store the results for later.
ResultSet * rs = stmt->executeQuery();
int counter = 0;
// Loop through retrieved records one-by-one and output the data.
while( rs->next() )
{
cout << "Result " << ++counter << ": "
<< rs->getString(1) << ' ' // SER
<< setw(10) << rs->getDouble(2) << ' ' // FRQ
<< setw(10) << rs->getDouble(3) << ' ' // XLA
<< setw(10) << rs->getDouble(4) << endl; // XLG
}
// Cleanup, close the allocated result set.
stmt->closeResultSet(rs);
}
// Cleanup, close the statement.
conn->terminateStatement(stmt);
}
else
{
cout << "Could not connect to the Oracle Database Server"
<< endl;
}
// More cleanup, terminate the connection to the database and the environment.
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}