QSqlDatabase db = QSqlDatabase::addDatabase("QOCI"); db.setDatabaseName("orcl"); db.setHostName("127.0.0.1"); db.setPort(1521); db.setUserName("xxxx"); db.setPassword("xxxxxx"); if(!db.open()) { qDebug() << db.lastError().text(); } else { qDebug() << "ok"; } QSqlQuery query(db); QString msg = QString("select * from ruiyTb1"); query.exec(msg); while (query.next()) { qDebug() << query.value(0).toString(); }