
Originally Posted by
ChrisW67
You don't say whether the database connection opens or not. The first line is a Qt warning, not an error. The warning results when OCIEnvCreate() (not a Qt function) fails. A quick search suggests this is either an incorrect ORACLE_HOME or permissions related: can your user read the directories under ORACLE_HOME?
#include <QtCore>
#include <QtSql>
#include <QSqlDatabase>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
qdb.setHostName("localhost");
qdb.setDatabaseName("test");
qdb.setUserName("postgres");
qdb.setPassword("1234");
qdb.setPort(1521);
if(qdb.open())
{
cout << "Database connection successful!" << endl;
}
else
{
cout << "Database connection not successful!" << endl;
}
qdb.close();
return 0;
}
#include <QtCore>
#include <QtSql>
#include <QSqlDatabase>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QSqlDatabase qdb = QSqlDatabase::addDatabase("QOCI");//If I replace "QOCI" = "QODBC" -> It's okay.
qdb.setHostName("localhost");
qdb.setDatabaseName("test");
qdb.setUserName("postgres");
qdb.setPassword("1234");
qdb.setPort(1521);
if(qdb.open())
{
cout << "Database connection successful!" << endl;
}
else
{
cout << "Database connection not successful!" << endl;
}
qdb.close();
return 0;
}
To copy to clipboard, switch view to plain text mode
How to fix error QOCIDriver: unable to create environment .Hizzzz
Bookmarks