Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:14

0001 #include <iostream>
0002 #include <string>
0003 #include <sstream>
0004 
0005 #include "occi.h"
0006 
0007 using namespace oracle::occi;
0008 using namespace std;
0009 
0010 int main(int argc, char *argv[]){
0011   int errCode = 0;
0012   if (argc==2){errCode = stoi(argv[1]);}
0013   if (errCode==24960){
0014     cout <<"Tesing: 'ORA-24960: the attribute  OCI_ATTR_USERNAME is greater than the maximum allowable length of 255'"<<endl;    
0015   }
0016   else if (errCode==12154){
0017     cout <<"Tesing: 'ORA-12154: TNS:could not resolve the connect identifier specified'"<<endl;    
0018   }
0019   else{
0020     cout<<"Testing exception error code:"<<errCode<<endl;
0021   }
0022   try
0023   {
0024     auto env = Environment::createEnvironment(Environment::OBJECT);
0025     auto conn = env->createConnection("a", "b", "c");
0026     env->terminateConnection(conn);
0027     Environment::terminateEnvironment(env);
0028   }catch(oracle::occi::SQLException &e)
0029   {
0030     cout <<"Caught oracle::occi::SQLException exception with error code: "<<e.getErrorCode()<<endl;
0031     cout <<"Exception Message:"<< e.getMessage()<<endl;
0032     if (e.getErrorCode()==errCode){
0033       cout << "OK: Expected exception found:" << errCode << endl;
0034     }
0035     else{
0036       throw;
0037     }
0038   }
0039   return 0;
0040 }