????1.???OCCI
???????oracle??????????а??OCCI??????????????????????????????汾??μ?API???????http://www.oracle.com/technetwork/topics/linuxsoft-082809.html  ?? ???а?????????????
????oracle-instantclient-sqlplus-10.2.0.5-1.i386.rpm
????oracle-instantclient-devel-10.2.0.5-1.i386.rpm
????oracle-instantclient-odbc-10.2.0.5-1.i386.rpm
????oracle-instantclient-basic-10.2.0.5-1.i386.rpm
?????????????????/usr/lib????oracle ?????????У???/usr/include????oracle ??????????????У?????????????????????У???????????汾??10.2.0??????????????
????2.??дHelloWorld????????????
#include <iostream>
#define LINUXOCCI //??????????????
#include <occi.h>
using namespace std;
using namespace oracle::occi;
int main()
{
Environment *env=Environment::createEnvironment(Environment::DEFAULT);
cout<<"success"<<endl;
string name = "scott";
string pass = "tiger";
string srvName = "127.0.0.1:1522/orcl";
try
{
Connection *conn = env->createConnection(name?? pass);
cout<<"conn success"<<endl;
env->terminateConnection(conn);
}
catch(SQLException e)
{
cout<<e.what()<<endl;
return -1;
}
Environment::terminateEnvironment(env);
cout<<"end!"<<endl;
return 0;
}
????????????
????g++
????test.cc -o test -I/usr/include/oracle/10.2.0.5/client -L/usr/lib/oracle/10.2.0.5/client/lib -locci -lsqlplus
????????н?occi??·???????????????У????????????г??????????????????????
????????./test?????libocci.so???????????????????/usr/lib/oracle/.../lib?μ?????LD_LIBRARY_PATH?п??????
????????????
????success
????conn
????success
????end!
??????????????????????????????????????????????????????????????????oracle????????????????????д????????????????????????????????
????ORA-12162:
????TNS:net service name is incorrectly specified
?????????????????????????????ò?????ORACLE_SID??????oracle??????????????????????????????????????????????Oracle?????????????????????????