oracle开发小结

c++ && occi 开发指南


1. 安装库
instantclient-sdk-linux.x64-12.2.0.1.0.zip (包含头文件)
instantclient-basic-linux.x64-12.2.0.1.0.zip




2. 编译
OCCI_INCLUDE_DIR=/home/fuanda/occi_test/instantclient_12_2/sdk/include
OCCI_LIBRARY_PATH=/home/fuanda/occi_test/instantclient_12_2
export LD_LIBRARY_PATH=$OCCI_LIBRARY_PATH:$LD_LIBRARY_PATH


g++ -o main main.cpp -I$OCCI_INCLUDE_DIR -L$OCCI_LIBRARY_PATH -locci -lclntsh




============================================
#include <iostream>
#define LINUXOCCI //避免函数重定义错误
#include <occi.h>
using namespace std;
using namespace oracle::occi;
int main()
{
    cout << "start\n";
   Environment *env=Environment::createEnvironment(Environment::THREADED_MUTEXED);
   cout<<"success"<<endl;
   string name = "lihl";
   string pass = "123456";
   string srvName = "192.168.1.125:1521/margin";
   try
   {
      Connection *conn = env->createConnection(name, pass, srvName);
      cout<<"conn success"<<endl;
      env->terminateConnection(conn);
   }
   catch(SQLException e)
   {
      cout<< "exception: " << e.what()<<endl;
       return -1;
   }
   Environment::terminateEnvironment(env);
   cout<<"end!"<<endl;
   return 0;
}


============================================


3. 运行
export ORACLE_HOME=/home/fuanda/occi_test/instantclient_12_2
#export NLS_LANG='simplified chinese'_china.ZHS16GBK
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
./main


4. 发布是仅需

instantclient-basic-linux.x64-12.2.0.1.0.zip


============================================================

python&&cx_Oracle 开发指南


1. 安装cx_Oracle
pip install cx_Oracle

2. 下载 instantclient-basic-linux.x64-12.2.0.1.0.zip, 安装库instantclient
mkdir -p /opt/oracle
cd /opt/oracle 
unzip instantclient-basic-linux.x64-12.2.0.1.0.zip


3. 安装libaio 包
yum install libaio


4. 配置库路径
如果没有其他oracle 库版本,可以使用
echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf
ldconfig
否则
export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值