Prerequisites
Here are the software and the versions used- OCI Instance Client
- instantclient-sdk-win32-11.1.0.7.0.zip
- instantclient-basiclite-win32-11.1.0.7.0.zip
- NetBeans 6.8
- Cygwin 1.7.1-1
- gdb 6.8
- make 3.81
- gcc 3.4.4
- g++ 3.4.4
Setup
- In NetBeans, create new project. Choose Category: C/C++ and Projects: C/C++ Application.
- Give project any name e.g. OCIDemo. Give main file any name e.g. main, but ensure its extension is C rather than C++.
- Copy paste code from cdemo81.c to main.c
- cdemo81.c is in d:/oracle/instantclient_11_1\sdk\demo
- Open OCIDemo project properties using right click on the project name in Project Windows (CTRL + 1).
- Go to Category Build -> C Compiler and add D:/oracle/instantclient_11_1/sdk/include to Include Directories
- Go to Category Build -> Linker and add D:/oracle/instantclient_11_1/oci.dll to Libraries (not same as Additional Library Directories)
Connection String
cdemo81.c uses scott account for the demo. AS no connection string is given, so edit the line(void) OCIServerAttach(srvhp, errhp, (text *) "", strlen(""), 0);
to
(void) OCIServerAttach(srvhp, errhp, (text *) "//localhost:1521/orcl", strlen("//localhost:1521/orcl"), (ub4) OCI_DEFAULT);
Note that on my machine SID is ORCL and its available on port 1521. Change this as per your instance setting.