Answer the question
In order to leave comments, you need to log in
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
#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
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 questionAsk a Question
731 491 924 answers to any question