Linux g++ compile C + + connection Oracle (OCCI) problems and Solutions
Original: http://lshirley2009.javaeye.com/blog/811301 article Category: C + + programmingAs a result of the project, began to learn C + +, just contact for more than half a month, today's reference online example, wrote a simple C + + connection to Oracle's demo, but the use of g++ compile time is not smooth, not the newspaper this fault is that, the last reference online solutions and personal understanding, finally The problems and solutions in compiling are summarized.
Source
C + + code #include <iostream> #include <string> #include " Occi.h " using namespace oracle::occi; using namespace std; Int main () { string usr= "SYS"; string pwd= "ORCL"; string sid= "ORCL"; string date; environment *env=environment::createenvironment (environment::object); connection *conn= env->createconnection (Usr,pwd,SID); all strings &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;IF (conn) cout<< "success createconnection! " <<endl; else cout<< "failure createconnection! " <<endl; statement *stmt = conn->createstatement (); string sSQL = "Select to_char (sysdate, ' yyyy-mm-dd hh24:mi:ss ') from dual"; stmt->setsql (sSQL); resultset *rs = stmt->executequery (); if (Rs->next ()) & NBsp; { date = rs->getstring (1); } cout<< "now &NBSP;TIME&NBSP: "<<date<<endl; env->terminateconnection (conn); Environment::terminateenvironment (env); return 0; } [C + +]View Plain copy print? #include <iostream> #include <string> #include "occi.h" using namespace Oracle::occi; using namespace Std; int main () {string usr= "sys"; String pwd= "ORCL"; String sid= "ORCL"; string date;