2

I had compiled oracle driver and opened successfully with Qt a few days ago, but today, I got into trouble using the same code! Here is the code:

bool isAvailable = QSqlDatabase::isDriverAvailable("QOCI");
if(isAvailable)
    qDebug() << "QOCI driver is available!";
else {
    qDebug() << "QOCI driver is not available!";
}
QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
db.setPort(1521);
db.setHostName("127.0.0.1");
db.setDatabaseName("orcl");
db.setUserName("c##scott");
db.setPassword("tiger");
bool ok = db.open();
if(ok) {
    qDebug() << "connect sucess!";
}

and message:

QOCI driver is available!
QSqlDatabase: QOCI driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QOCI QOCI8 QODBC 
QODBC3 QPSQL QPSQL7

The version of Qt is 5.9.0, and oracle is 12c. I am so upset for this problem, who can help me?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Mr.Guo
  • 21
  • 4
  • 1
    If Qt driver is available but cannot be loaded, it usually means that the underlying API is missing or broken. Check your Oracle client API (OCI) installation, PATH etc. – Matt Dec 09 '17 at 14:55
  • Complementary hint: check if the OCI is in the same version (32 ou 64 bits) as the one you needed. I had this problem and this was the cause. – Momergil Nov 12 '18 at 13:51
  • Got the same problem, although I tried to connect to Oracle 11g database. My setup was to move from Qt5.9/instant oracle 11 to Qt5.12. I could not keep instant oracle 11 because compilation error, so I had to move to instant oracle 12.1, but I could not take any other version: instant oracle 12.2 lead to this same error (driver not loaded whereas it is in the list, and is compatible version), and instant oracle 18+ crash with "GetOverlappedResultEx" not found in kernel32.dll (target platform is Windows7/mingw) – Alexis Sep 02 '19 at 10:36

0 Answers0