D
D
Denis2013-12-12 12:48:08
Oracle
Denis, 2013-12-12 12:48:08

QT and Oracle: QSqlDatabase: QOCI driver not loaded

I needed to make an application for connecting to the Oracle database.
I use: Arch Linux x86-64 and QTCreator.
I never really worked with such databases, I found a simple example on the Internet that connects to the database.
Collected, run:

QSqlDatabase: QOCI driver not loaded
QSqlDatabase: available drivers: QIBASE QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
QSqlQuery::exec: database not open

Of course, there is not enough library to work with Oracle.
It was only possible to google the name of the lib: libqsqloci.so
Question: where can I get it?
It's not banned on Google, but I couldn't find it myself.
The code of the "application" itself:
#include <QtWidgets>
#include <QtSql>
int main(int argc,char* argv[])
{
    QApplication app(argc,argv);
    QTableView table;
    table.setWindowTitle("QT-Connect to Oracle Database");

    QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
    db.setHostName("host");
    db.setDatabaseName("dbname");
    db.setUserName("user");
    db.setPassword("passwd");

    if (!db.open())
    {
      QMessageBox::critical(0, QObject::tr("Database Error"),
                db.lastError().text());
    }

    QSqlQuery query;
    query.exec("select * from v$version");

    QSqlQueryModel model;
    model.setQuery(query);
    table.setModel(&model);
    table.resizeColumnsToContents();
    table.resize(450,250);

    table.show();
    return app.exec();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GentleHedgehog, 2019-02-20
@GentleHedgehog

The process of creating this plugin is detailed here:
https://stackoverflow.com/questions/29508725/qt-co...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question