1) Software Using:
Microsoft Windows Vista
Microsoft Visual Studio 2008 (VS9)
Oracle Instant Client Version 11.1.0.6.0 (mirror)
Oracle C++ Call Interface Version 11.1.0.6.0 (mirror)
2) Create OCCI Directories:
D:\app\oracle_occi\vc9\include // for header files
D:\app\oracle_occi\vc9\lib // for libs
3) Unpack OCCI Header Files:
instantclient-sdk-win32-11.1.0.6.0.zip => D:\app\oracle_occi\vc9\include
4) Unpack OCCI Libs:
instantclient-sdk-win32-11.1.0.6.0.zip => D:\app\oracle_occi\vc9\lib
occivc9win32_111060.zip (with override) => D:\app\oracle_occi\vc9\lib
5) Setup Windows PATH:
D:\app\oracle_occi\vc9\lib // with libs location
6) Setup VC++ Directories:
D:\app\oracle_occi\vc9\header // with header location
D:\app\oracle_occi\vc9\lib // with libs location
7) Setup VC++ Project Libs:
oraocci11.lib // for Release
oraocci11d.lib // for Debug
8) Run OCCI Test:
#include <occi.h>
#include <iostream>
#include <string>
using namespace oracle::occi;
int main() {
try {
//create environment and connection
Environment* env = Environment::createEnvironment();
Connection* conn = env->createConnection("scott", "tiger", "localhost:1521/XE");
std::cout << "Environment and Connection created." << std::endl;
//execute a SQL statement
Statement* stmt = conn->createStatement();
stmt->setSQL("insert into occi(id, text) values(2, 'c++')");
stmt->execute();
conn->terminateStatement(stmt);
//terminate environment and connection
conn->commit();
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
std::cout << "Environment and Connection terminated." << std::endl;
}
catch (SQLException e) {
std::cout << e.getMessage() << std::endl;
}
std::cout << "DONE; press enter to exit..." << std::endl;
std::string done;
std::getline(std::cin, done);
return 0;
}
PS: Database Setup:
SQL> connect scott/tiger@XE
SQL> create table occi(id int, text varchar2(30));
%%
No comments:
Post a Comment