???OCCI????Linux??Oracle?????
???????????? ???????[ 2014/4/9 10:39:56 ] ??????????????? ???? ?????
????OCCI??Oracle C++ Call Interface????C++??????Oracle???????????????ó??????????????????????????????OCCI??OCI??????????????????????OCI
????OCCI????Linux?μ?Oracle?????
????1 ???Linux?μ?oracle?????
????2 ????????oracle-instantclient-basic-10.2.0.4-1.i386.zip???俽????Linux??Oracle??????????instantclient_10_2??
???????OCCI???????裺
????1 ????????????Environment
????2 ???????????Connection
????3 ????SQL??????ж???Statement
????4 ???SQL???execute??????????executeUpdate()??????executeQuery??????????
????5 ????????ResultSet??????????
????6 ???????
??????Linux??Oracle??????′???????????????
create table user_info
(
user_id int not null primary key??
user_name varchar2(100)
);
//AddOcci.cc
#include <iostream>
#include <string>
#include <occi.h>
#pragma comment(lib??"oci.lib")
#pragma comment(lib??"ociw32.lib")
#pragma comment(lib??"oraocci10.lib")
using namespace std;
using namespace oracle::occi;
/*******************************
*??????????????????
*******************************/
int main()
{
//????????????
//Environment
Environment *env = Environment::createEnvironment(Environment::OBJECT);
//username??oracle???????
//userpass??oracle??????
//connstr??oracle???????????
string username = "hahaya";
string userpass = "hahaya";
string connstr = "192.168.0.6:1521/orcl";
//????????
//connection
Connection *conn = env->createConnection(username?? userpass?? connstr);
if(conn == NULL)
{
cout << "access oracle failed..." << endl;
return 0;
}
//???????SQL??????ж???
//statement
Statement *st = conn->createStatement();
st->setSQL("insert into user_info values(1?? 'hahaya')");
st->executeUpdate();
//???????
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11