打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
OCCI例子
Hi,

What VS version are you using? I have VS7 and I got OCCI working as:

- Download the following from Oracle site:

instantclient-sdk-win32-10.2.0.1-20050930.zip
instantclient-basic-win32-10.2.0.1-20050930.zip

- Create empty Win32 Console Project.
- Create folder myproject\src in the new project directory.
- Create myproject\src\include and myproject\src\lib

- Unzip the sdk and basic client files and copy:
-- all *.h files ftrom instantclient_10_2\sdk\include to
myproject\src\include
-- copy two libraries oci.lib and oraocci10.lib from
\instantclient_10_2 to myproject\src\lib

- Put your myproject.cpp into \myproject\src

- In the VS7 UI:

1. Project Properties -> C/C++ -> General -> Additional Include
Directories ->
add ...\myproject\src\include

2. Project Properties -> C/C++ -> Preprocessor -> Preprocessor
Definitions ->
add WIN32COMMON;_DLL;_MT to the existing value

3. Project Properties -> Linker -> General ->Additional Library
Directories ->
add ...\myproject\src\lib

4. Project Properties -> Linker -> Input -> Additional Dependencies ->
add: oci.lib msvcrt.lib msvcprt.lib oraocci10.lib

5. Project Properties -> Linker -> Input -> Ignore All Default
Libraries ->
change it to Yes(/NODEFAULTLIB)

- Copy instantclient_10_2\oci.dll and instantclient_10_2\oraocci10.dll
from the unzipped basic client directory to \myproject\Debug


Julia
 
I gave up with the occidml example and restarted with
the occiobj example. And guess what happened. It
worked. I can´t beleive it.

So I really don´t know what the difference of these
two example is as the only difference so far (as I
saw in the constructor of the two classes) is an extra
call in the occiobj-example. Well the parameters
are also different.

Occidml-example constructor:

occidml (string user, string passwd, string db)
{
env = Environment::createEnvironment (Environment::DEFAULT);
conn = env->createConnection (user, passwd, db);
}

Occiobj-example constructor:

occiobj (string user, string passwd, string db)
{
env = Environment::createEnvironment (Environment::OBJECT);
occiobjm (env);
con = env->createConnection (user, passwd, db);
}

If I have time again I will give the occidml another try. By far
I get along with the occiobj-example.

Thanks for all the people who helped me (or intended to).

Greetings Roman
 
I had all of the same problems in this thread.

What I discovered is that the reason for the problems is that MS VC++ Express likes the to bind with the newer versions of the libraries? (The 8.0 libraries for thread safety and debugging.)

I did get the examples to work with MS VC++ Express in a limited fashion.

I used the DEBUG version and I locallized the DLL to the project.

===================
After I confirmed this, I then switch machines and used MS VC++ 2003 and the exact same example worked perfectly.

Note: I did have to create a new project but I just used the link paths and the same instant client.

The example works! (Just with the 2003 version)

..DTate..
 
 
#include <occi.h>
#include <iostream>
using namespace oracle::occi;
using namespace std;
class occidemo
{
private :
    Environment *env;
    Connection *conn;
    Statement *stmt;
public :
    occidemo(string user, string passwd, string db)
    {
  env = Environment::createEnvironment(Environment::OBJECT);
        conn = env->createConnection(user, passwd, db);
    }
    ~occidemo()
    {
        env->terminateConnection(conn);
        Environment::terminateEnvironment(env);
    }
    void insertRow()
    {
        try
        {
            stmt = conn->createStatement("insert into author_tab(author_id, author_name) values(:id, :name)");
            stmt->setInt(1, 1);
            stmt->setString(2, "Brice");
            stmt->executeUpdate();
        }catch(SQLException e)
        {
            cout << "Exception thrown for insertRow" << endl;
            cout << "Error number: " << e.getErrorCode() << endl;
            cout << e.getMessage() << endl;
        }
        cout << "Insertion - Successful" << endl;
        conn->terminateStatement(stmt);
    }
};
int main()
{
    string user = "system";
    string passwd = "abc123_";
    string db = "orcl";
   
    try
    {
        cout << "occidemo for insert data on the table author_tab" << endl;
       
        occidemo *demo = new occidemo(user, passwd, db);
        demo->insertRow();
  //cout << "OCIAttrGet with OCI_ATTR_USERNAME = " << OCIAttrGet((void*)OCI_ATTR_USERNAME, NULL, NULL, NULL, NULL, NULL) << endl;
        cout << "occidemo done" << endl;
  getchar();
    }catch(SQLException e)
    {
        cerr << "Error running the demo: " << e.getMessage () << endl;
    }
   
    return 0;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
OCCI基础教程(一)
通过OCCI操作Oracle数据库详解
转:c ?Oracle?OCCI?编程
JNI之C++调用Java类 —— java.lang.String
使用node
tr1中新增加的tuple介绍
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服