Solved Cannot connect to databases, Driver not loaded error.
-
Debug VS Release version of the plugin ?
-
Sorry, I don't understand the question :(
Are you asking me to compare two different builds of the same plugin? -
Did you build your plugin for both debug and release ?
-
need dynamic lib for mysql. For linux it's libmysqlclient.so.16 or libmysqlclient.so.18 for your target platform.
-
@SGaist I built just one, with the default configuration. I will check which one when I get back to my home pc. What difference does it make? Could it work with one but not the other one?
@Homer2000 I am using a shared library, except my distribution [like many others] now uses MariaDB as a replacement for MySQL, so I link to
libmariadb.so
or something similar -
@mleoni said in Cannot connect to databases, Driver not loaded error.:
MariaDB
MariaDB use libqsqlmysql plugin?
-
@Homer2000 No, by default the Qt MySQL plugin links against the MySQL client libraries.
You can build it to use MariaDB though.
-
Ok, I found out what I was doing wrong.
The code that I was using isQSqlDatabase db; db.addDatabase("QMYSQL");
and it was giving me the error above, whereas the correct way to do it is
QSqlDatabase db; db = QSqlDatabase::addDatabase("QMYSQL");
and with this code it works fine.
I don't know why this is the case, I guess today I just learnt something new on Qt, thanks for the help everyboody!
-
@mleoni said in Cannot connect to databases, Driver not loaded error.:
I don't know why this is the case,
Because QSqlDatabase::addDatabase() is a static function - no Qt magic here.
-
I see, so my mistake was letting the returned value go lost. Thanks for clarifying this!
-
Please take the time to read the QSqlDatabase documentation. It shows how to use it properly.
-
Thanks for the reference!