2

前几天我编译了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。我为这个问题而烦恼,谁能帮助我?

4

0 回答 0