1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| #include "ocilib.h"
#include "InsORA.h"
#include "GesErr.h"
#include "../MesFonctions.h"
#include <string>
#include <iostream>
using namespace std;
//constructeur
InsORA::InsORA(const char* a, const char* b, const char* c, int d) :
Instance(a),
Utilisateur(b),
MdP(c),
MatriculeAgent(d)
{
}
bool InsORA::connexionBase()
{
HINSTANCE hinstLib = LoadLibrary(TEXT("ociliba.dll"));
if (hinstLib == NULL) {
cout << "ERREUR: impossible de charger la DLL " << endl;
FreeLibrary(hinstLib);
return false;
}
cn=NULL;
importF13 ociGetLastError;
ociGetLastError = (importF13)GetProcAddress(hinstLib, "_OCI_GetLastError@0");
if (ociGetLastError == NULL) {
cout << "ERREUR: impossible de trouver dans la DLL la fonction '_OCI_GetLastError@0'" << endl;
FreeLibrary(hinstLib);
return false;
}
importF20 ociInitialize;
ociInitialize = (importF20)GetProcAddress(hinstLib, "_OCI_Initialize@12");
if (ociInitialize == NULL) {
cout << "ERREUR: impossible de trouver dans la DLL la fonction '_OCI_Initialize@12'" << endl;
FreeLibrary(hinstLib);
return false;
}else if(!ociInitialize(NULL, NULL, OCI_ENV_CONTEXT )){
GesErr::err_handler(ociGetLastError());
FreeLibrary(hinstLib);
return false;
}
/*
...encore du code...
*/
FreeLibrary(hinstLib);
return true;
}
void InsORA::deconnexionBase(){
//OCI_ConnectionFree(cn);
//OCI_Cleanup();
}
string InsORA::getInstance(){return Instance;}
string InsORA::getUtilisateur(){return Utilisateur;}
string InsORA::getMdP(){return MdP;}
OCI_Connection *InsORA::getObjCn(void)
{
return this->cn;
}
void InsORA::Affiche()
{
//cout << Instance << ", " << Utilisateur << ", " << MdP << endl;
cout << endl;
/*
cout << OCI_GetVersionServer(cn) << endl;
cout << "Server major version : " << OCI_GetServerMajorVersion(cn)<< endl;
cout << "Server minor version : " << OCI_GetServerMinorVersion(cn)<< endl;
cout << "Server revision version : " << OCI_GetServerRevisionVersion(cn)<< endl;
cout << "Connection version : " << OCI_GetVersionConnection(cn)<< endl;
*/
}
//destructeur
InsORA::~InsORA(){} |
Partager