Hi verybody.
I'm trying to connect Oracle Database using QOCI Driver.
I used QT Eclipse Plugin + MINGW + Eclipse C++ + Window 7.
I complied OCI.DLL success.
But when I run my code here:
#include <QApplication>
#include <QtSql>
#include <QtPlugin>
#include <iostream>
using namespace std;
/* Change these to match your database */
#define HOST "127.0.0.1"
#define DB "xe"
#define PORT 1521
#define USER "testbed"
#define PASSWD "secre3t"
int main(int argc, char *argv[])
{
// QSqlDatabase db = QSqlDatabase::addDatabase(ociDriver->create("QOCI"));
qDB.setHostName(HOST);
qDB.setDatabaseName(DB);
qDB.setPort(PORT);
qDB.setUserName(USER);
qDB.setPassword(PASSWD);
/* Probably overkill ;) */
qDB.setConnectOptions("Prefetch_Memory=5242880;Prefetch_Rows=250");
if (qDB.open() == FALSE) {
cout<< "Error: opening DB failed because " << qDB.lastError().text().toStdString();
return -1;
}
return 0;
}
#include <QApplication>
#include <QtSql>
#include <QtPlugin>
#include <iostream>
using namespace std;
/* Change these to match your database */
#define HOST "127.0.0.1"
#define DB "xe"
#define PORT 1521
#define USER "testbed"
#define PASSWD "secre3t"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// QSqlDatabase db = QSqlDatabase::addDatabase(ociDriver->create("QOCI"));
QSqlDatabase qDB = QSqlDatabase::addDatabase("QOCI");
qDB.setHostName(HOST);
qDB.setDatabaseName(DB);
qDB.setPort(PORT);
qDB.setUserName(USER);
qDB.setPassword(PASSWD);
/* Probably overkill ;) */
qDB.setConnectOptions("Prefetch_Memory=5242880;Prefetch_Rows=250");
if (qDB.open() == FALSE) {
cout<< "Error: opening DB failed because " << qDB.lastError().text().toStdString();
return -1;
}
return 0;
}
To copy to clipboard, switch view to plain text mode
Errors:
QOCIDriver: unable to create environment
QOCIDriver:: parseArgs: Invalid parameter: 'Prefetch_Memory'
QOCIDriver:: parseArgs: Invalid parameter: 'Prefetch_Rows'
Unable to free Error handle: -1
Unable to free Environment handle: -1
I set variables enviroment here:
Name: Path
Value: C:\oraclexe\app\oracle\product\11.2.0\server\bin;; C:\app\nguyenluuvu\product\11.2.0\client;C:\app\ng uyenluuvu\product\11.2.0\client_1\bin;E:\app\nguye nluuvu\product\11.2.0\client_1;C:\app\MAY02\produc t\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%Syste mRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\Sys tem32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Prog ram Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseHg\;C:\MinGW\bin\; C:\msys\1.0\bin\;C:\luuvu\MinGW\bin;C:\Program Files\CMake 2.8\bin;C:\luuvu\qt\bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\OPENCV;C:\App\nguyenluuvu\product\11.2.0\cli ent_1\oci\include;C:\App\nguyenluuvu\product\11.2. 0\client_1\oci\lib\msvc;C:\Windows\System32;C:\luu vu\qt\plugins\sqldrivers\qopenocci.dll;C:\oraclexe \app\oracle\product\11.2.0\instantclient_11_2;C:\o raclexe\app\oracle\product\11.2.0\server\bin;C:\Wi ndows\System32;C:\oraclexe\app\oracle\product\11.2 .0\server\oci\lib\MSVC;C:\oraclexe\app\oracle\prod uct\11.2.0\server\oci\include
Can you help me?
Thanks so much!
Bookmarks