[Solved] QMYSQL Driver not loadad but available
-
Dear Sirs,
as I try to connect to an existing MySQL Database I get "Driver not loaded" in QSqlDatabase::lastError ().
The ooutput of QApplication::libraryPaths () is: ("/usr/lib/qt4/plugins", "/home/ernie/src/recipe") which is correct. Most irritable is the output of QSqlDatabase::drivers () which is "("QSQLITE", "QMYSQL3", "QMYSQL")" so it seems that QMYSQL driver should be available. Also I have tried to use Environment variable QT_DEBUG_PLUGINS set to 1 which generates the following output:@QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/inputmethods/libqimsw-multi.so"
keys ("imsw-multi")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/sqldrivers/libqsqlite.so"
keys ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so"
keys ("QMYSQL3", "QMYSQL")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
keys ("svg", "svgz", "svg.gz")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqgif.so"
keys ("gif")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqico.so"
keys ("ico")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqjpeg.so"
keys ("jpeg", "jpg")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqmng.so"
keys ("mng")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqsvg.so"
keys ("svg")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqtiff.so"
keys ("tiff", "tif")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
keys ("svg", "svgz", "svg.gz")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
keys ()@This results in two different developement environments, one is debian squeeze (6.0), that is Qt 4:4.6.3-4, and one in an user local directory, which ist Qt 4.7.0 rom source.
Thank you for your kindness
Henrik K.
-
That is very strange. The listing you post, as well as QMYSQL being in the list of drivers, is really indicative of the driver being loaded successfully. Could you post the code where you create the database connection?
-
Thanks for your reply. Here is my connection code:
The error was: I did not see that QApplication::addDatabase () is a static function.Thanks for your help.
Henrik K.
-
You did not actually post the code, but I gather you managed to fix the problem.
-
Wrong code was:
@QSqlDatabase db;
db.addDatabse ("QMYSQL");@
which I corrected to
@QSqlDatabase db = QSqlDatabase::addDatabase ("QMYSQL");@
This solved the problem.Yours
Henrik K. -
it's too strange ,but i have solves this problem luckily ,thank you