March 15, 2011

henrikk henrikk
Lab Rat
2 posts

[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:

  1. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/inputmethods/libqimsw-multi.so"
  2. keys ("imsw-multi")
  3. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/sqldrivers/libqsqlite.so"
  4. keys ("QSQLITE")
  5. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so"
  6. keys ("QMYSQL3", "QMYSQL")
  7. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
  8. keys ("svg", "svgz", "svg.gz")
  9. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqgif.so"
  10. keys ("gif")
  11. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqico.so"
  12. keys ("ico")
  13. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqjpeg.so"
  14. keys ("jpeg", "jpg")
  15. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqmng.so"
  16. keys ("mng")
  17. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqsvg.so"
  18. keys ("svg")
  19. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqtiff.so"
  20. keys ("tiff", "tif")
  21. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
  22. keys ("svg", "svgz", "svg.gz")
  23. QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
  24. 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.

4 replies

March 15, 2011

Andre Andre
Robot Herder
6422 posts

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?

March 15, 2011

henrikk henrikk
Lab Rat
2 posts

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.

March 15, 2011

Andre Andre
Robot Herder
6422 posts

You did not actually post the code, but I gather you managed to fix the problem.

March 15, 2011

henrikk henrikk
Lab Rat
2 posts

Wrong code was:

  1. db.addDatabse ("QMYSQL");

which I corrected to
  1. QSqlDatabase db = QSqlDatabase::addDatabase ("QMYSQL");

This solved the problem.

Yours
Henrik K.

 
  ‹‹ Develop application fully Qt coded for iPhone,iPad,iPod.      Packaging Qt applications on desktop platforms. ››

You must log in to post a reply. Not a member yet? Register here!