[SOLVED] sql driver plugins not loadded
-
this->dbo->setHostName(hostname);
this->dbo->setDatabaseName(databasename);
this->dbo->setUserName(username);
this->dbo->setPassword(password);
if (!this->dbo->open()) {
qDebug()<<"Database Error"<<this->dbo->lastError().text()<<endl;
return false;
}I got "Driver not loaded Driver not loaded" error.
Why is it twice? -
Looks like you are doing something unusual.
QSqlDatabase's initialization should rather look like:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL") db.setHostname(hostname); etc.
How are you doing it ?
Another thing that is puzzling is that your plugin list is empty.
What does
qDebug() << QSqlDatabase::drivers();
return ? -
This is the full code of creation of database connection.
bool Factory::createConnection()
{
qDebug()<<"Connection has been creating"<<endl;
this->dbo = new QSqlDatabase(QSqlDatabase::addDatabase("QMYSQL"));
this->setting->beginGroup("database");
QString hostname = this->setting->value("host").toString();
QString username = this->setting->value("user").toString();
QString password = this->setting->value("password").toString();
QString databasename = this->setting->value("databasename").toString();qDebug()<<"password : "<<password<<endl; this->dbo->setHostName(hostname); this->dbo->setDatabaseName(databasename); this->dbo->setUserName(username); this->dbo->setPassword(password); if (!this->dbo->open()) { qDebug() <<"Available Drivers : " << QSqlDatabase::drivers()<<endl; qDebug()<<"Database Error : "<<this->dbo->lastError().text()<<endl; return false; } qDebug()<<"Database connected"<<endl; return true;
}
Output of this program.
Plugins location "/home/ckurdu/bin/Qt_5_4.1/5.4/gcc_64/plugins"
Plugins Prefixpath "/home/ckurdu/bin/Qt_5_4.1/5.4/gcc_64"
Factory loaded
Connection has been creating
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
password : "wqerqwefas"**Available Drivers : () **
**Database Error : "Driver not loaded Driver not loaded" **Module not loaded
"The shared library was not found."
Module not loaded
"The shared library was not found."
-
Did you build Qt yourself ?
-
No
I only built myself libqsqlmysql.so. Also I installed qt 5.4.1 3 hours ago.
My os is Opensuse 13.2 64 bit. -
Might sound silly, but did you also installed it ? I'm still puzzled by that empty list of drivers...
-
Are you doing a deployment ?
-
Actually I have a main program that has already deployed for my desktop computer and I am programming a module for it. I copied the program from my desktop to my laptop than I continued to develop my module where I left off. But I forget to change "my.conf" file for the main program.
Thank you.
-
Wouldn't it be simpler also for debugging to build both ?
In any case, since you have it working now, please mark the thread as solved so other forum users may know a solution has been found :)