我已经编译了oracle驱动程序并且几天前用Qt成功打开了,但今天我使用相同的代码遇到了麻烦!这是代码:
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!";
}
和消息:
QOCI driver is available!
QSqlDatabase: QOCI driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QOCI QOCI8 QODBC
QODBC3 QPSQL QPSQL7
Qt的版本是5.9.0,oracle是12c。我对这个问题感到很沮丧,谁可以帮助我?