# OCILIB - C and C++ Drivers for Oracle
OCILIB is an open source and cross platform Oracle Driver that delivers efficient access to Oracle databases.
The OCILIB library :
OCILIB is developed by Vincent Rogier. Get the latest package, install and enjoy it!
The source code is free source code licensed under Apache License, Version 2.0 - see LICENSE file
su
to make install)Make sure Oracle and OCILIB libraries paths are defined in your shared library environment variable You need to provide extra configure parameters when using Instant Clients – see Installation section)
Example of a minimal OCILIB C application
#include "ocilib.h"
int main(int argc, char *argv[])
{
OCI_Connection* cn;
OCI_Statement* st;
OCI_Resultset* rs;
OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
st = OCI_StatementCreate(cn);
OCI_ExecuteStmt(st, "select intcol, strcol from table");
rs = OCI_GetResultset(st);
while (OCI_FetchNext(rs))
{
printf("%i - %s\n", OCI_GetInt(rs, 1), OCI_GetString(rs,2));
}
OCI_Cleanup();
return EXIT_SUCCESS;
}
Example of a minimal OCILIB C++ application
#include "ocilib.hpp"
using namespace ocilib;
int main(void)
{
try
{
Environment::Initialize();
Connection con("db", "usr", "pwd");
Statement st(con);
st.Execute("select intcol, strcol from table");
Resultset rs = st.GetResultset();
while (rs.Next())
{
std::cout << rs.Get<int>(1) << " - " << rs.Get<ostring>(2) << std::endl;
}
}
catch(std::exception &ex)
{
std::cout << ex.what() << std::endl;
}
Environment::Cleanup();
return EXIT_SUCCESS;
}