Results 1 to 3 of 3

Thread: The strange problem:"QSqlDatabase: QMYSQL driver not loaded"

  1. #1
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Angry The strange problem:"QSqlDatabase: QMYSQL driver not loaded"

    Hi,
    Everyone!

    I have a strange problem with below code:
    Qt Code:
    1. #include <QtSql/QSqlDatabase>
    2. #include <QMessageBox>
    3. #include <QString>
    4. #include <QApplication>
    5.  
    6.  
    7.  
    8. bool ConnectDb( const QString& hostName,
    9. const QString& dbName,
    10. const QString& usrName,
    11. const QString& pwd )
    12. {
    13.  
    14. QSqlDatabase db = QSqlDatabase::addDatabase( QString( "QMYSQL" ) );
    15.  
    16. db.setHostName( hostName );
    17. db.setDatabaseName( dbName );
    18. db.setUserName( usrName );
    19. db.setPassword( pwd );
    20.  
    21. return db.open();
    22.  
    23. }
    24.  
    25. int main( int argc, char** argv )
    26. {
    27.  
    28. QApplication app( argc, argv );
    29.  
    30. bool dbConnected = ConnectDb( "osmanthus-desktop", "MYDB",
    31. "mysql", "godfather1943@" );
    32.  
    33. if( dbConnected )
    34. {
    35. QMessageBox::information( 0, QString( "Message" ),
    36. QString( "DB Connected" ) );
    37. }
    38.  
    39. else
    40. {
    41. QMessageBox::information( 0, QString( "Message" ),
    42. QString( "DB Not Connected!" ) );
    43. }
    44.  
    45. return app.exec();
    46.  
    47. }
    To copy to clipboard, switch view to plain text mode 

    run this code,the error is:
    Qt Code:
    1. QSqlDatabase: QMYSQL driver not loaded
    To copy to clipboard, switch view to plain text mode 

    my os is ubuntu 8.04
    before i install qt4,run below command:
    ./configure -qt-sql-mysql -I /usr/include/mysql -L/usr/lib/mysql
    Please give me a hand.Thank you very much!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: The strange problem:"QSqlDatabase: QMYSQL driver not loaded"

    did you add path to mysql lib in LD_LIBRARY_PATH?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: The strange problem:"QSqlDatabase: QMYSQL driver not loaded"

    What does
    bash Code:
    1. ldd libqmysql.so
    To copy to clipboard, switch view to plain text mode 
    output? It's located in $QTDIR/plugins/sqldrivers.
    J-P Nurmi

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. Help with QMYSQL driver for QT 4.4.0: driver not loaded
    By khikho in forum Installation and Deployment
    Replies: 4
    Last Post: 1st April 2011, 16:00
  3. QMYSQL driver not loaded
    By sepehr in forum Qt Programming
    Replies: 12
    Last Post: 11th January 2009, 21:15
  4. mysql 5 connection
    By GuL in forum Newbie
    Replies: 37
    Last Post: 18th August 2008, 16:11
  5. exception at 0x65100c40 (QtGuid4.dll)
    By sabeesh in forum Qt Programming
    Replies: 11
    Last Post: 21st December 2007, 18:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.