Linux g++ compile C + + connection Oracle (OCCI) Problems and solutions

Source: Internet
Author: User
Tags stmt
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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.