Page 1 of 2 12 LastLast
Results 1 to 20 of 38

Thread: mysql 5 connection

  1. #1
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default mysql 5 connection

    Im trying to connect to a mysql server with this code:

    Qt Code:
    1. #include "testemysql1.h"
    2. #include <QSqlDatabase>
    3. #include <QtSql>
    4. #include <QMessageBox>
    5.  
    6. testeMYSQL1::testeMYSQL1(QWidget *parent, Qt::WFlags flags)
    7. : QMainWindow(parent, flags)
    8. {
    9. ui.setupUi(this);
    10. }
    11.  
    12. testeMYSQL1::~testeMYSQL1()
    13. {
    14.  
    15. }
    16.  
    17.  
    18. void testeMYSQL1::on_pushButton_clicked()
    19. {
    20. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    21. db.setHostName("servidor");
    22. db.setDatabaseName("teste");
    23. db.setUserName("root");
    24. db.setPassword("");
    25. if (!db.open())
    26.  
    27. QMessageBox::critical(0, tr("Error"), QString("The error:\n%1").arg(db.lastError().text()));
    28.  
    29. // bool ok = db.open();
    30. //lineEdit
    31. }
    To copy to clipboard, switch view to plain text mode 

    But I got this error:

    Qt Code:
    1. QSqlDatabase: QMYSQL driver not loaded
    2. QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
    To copy to clipboard, switch view to plain text mode 

    Im using QT4.4 Commercial and Visual Studio 2005.

    Thanks in advance
    Renan

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

    Default Re: mysql 5 connection

    You don't seem to have the MySQL plugin. See How to Build the QMYSQL Plugin on Windows.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    GuL (11th August 2008)

  4. #3
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    But it shouldn't be instaled by default with a commercial version of qt?

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

    Default Re: mysql 5 connection

    One would assume so, but I don't remember for sure. Which files do you have in %QTDIR%\plugins\sqldrivers?
    J-P Nurmi

  6. #5
    Join Date
    Jul 2006
    Location
    Atlanta, GA
    Posts
    86
    Thanks
    26
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    Don't forget to put the QT+= sql in your project file
    fnmblot
    --------------------------------------
    Gee Ricky, I'm sorry your mom blew up.

  7. #6
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    Qt Code:
    1. 23/04/2008 18:54 372.736 qsqlite4.dll
    2. 23/04/2008 18:54 2.062 qsqlite4.lib
    3. 23/04/2008 18:54 561.152 qsqlited4.dll
    4. 23/04/2008 18:54 2.074 qsqlited4.lib
    5. 23/04/2008 19:35 65.536 qsqlmysql4.dll
    6. 23/04/2008 19:35 2.088 qsqlmysql4.lib
    7. 23/04/2008 19:35 135.168 qsqlmysqld4.dll
    8. 23/04/2008 19:35 2.100 qsqlmysqld4.lib
    9. 23/04/2008 18:54 86.016 qsqlodbc4.dll
    10. 23/04/2008 18:54 2.074 qsqlodbc4.lib
    11. 23/04/2008 18:54 159.744 qsqlodbcd4.dll
    12. 23/04/2008 18:54 2.088 qsqlodbcd4.lib
    13. 23/04/2008 19:36 126.976 qsqlpsql4.dll
    14. 23/04/2008 19:36 2.074 qsqlpsql4.lib
    15. 23/04/2008 19:36 245.760 qsqlpsqld4.dll
    16. 23/04/2008 19:36 2.088 qsqlpsqld4.lib
    To copy to clipboard, switch view to plain text mode 

    Those are the files.

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

    Default Re: mysql 5 connection

    Ok so it is there. What if you open qsqlmysql4.dll to dependency walker. Can you see any missing dependencies?
    J-P Nurmi

  9. #8
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    Well, here is what Dependency Walker has found:

    Error: At least one required implicit or forwarded dependency was not found.
    Warning: At least one delay-load dependency module was not found.
    Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

    LIBMYSQL.DLL and
    MSJAVA.DLL


    At least LIBMYSQL.DLL I know I have... But where should they be placed?

    Renan

  10. #9
    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: mysql 5 connection

    you can put path to mysql directory in PATH variable.
    for example:
    set PATH=C:\mysql\bin;%PATH%

  11. #10
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    libmysql.dll is in my PATH now. Im trying to find MSJAVA.DLL now.

    Renan

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

    Default Re: mysql 5 connection

    Quote Originally Posted by GuL View Post
    libmysql.dll is in my PATH now. Im trying to find MSJAVA.DLL now.

    Renan
    The libmysql.dll should be enough. msjava.dll can be safely ignored, see dependency walker faq for more details.
    J-P Nurmi

  13. #12
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    Here is the output window in VS2005:

    'testeMYSQL1.exe': Loaded 'C:\Documents and Settings\Renan\Meus documentos\Visual Studio 2005\Projects\testeMYSQL1\debug\testeMYSQL1.exe', Symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\Utils\Qt\4.4.0\bin\QtCored4.dll', Symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\msvcp71d.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\msvcr71d.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\Utils\Qt\4.4.0\bin\QtGuid4.dll', Symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\comdlg32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\winspool.drv', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\Utils\Qt\4.4.0\bin\QtSqld4.dll', Symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc 8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcr80d.dll', Symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc 8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcp80d.dll', Symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\avgrsstx.dll', No symbols loaded.
    'testeMYSQL1.exe': Unloaded 'C:\WINDOWS\system32\avgrsstx.dll'
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\xpsp2res.dll', Binary was not built with debug information.
    The thread 'Win32 Thread' (0xa9c) has exited with code 0 (0x0).
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL

    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\wintrust.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\crypt32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\msasn1.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', No symbols loaded.
    'testeMYSQL1.exe': Unloaded 'C:\WINDOWS\system32\setupapi.dll'
    'testeMYSQL1.exe': Unloaded 'C:\WINDOWS\system32\wdmaud.drv'
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll', No symbols loaded.
    'testeMYSQL1.exe': Unloaded 'C:\WINDOWS\system32\setupapi.dll'
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\msacm32.drv', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\msacm32.dll', No symbols loaded.
    'testeMYSQL1.exe': Loaded 'C:\WINDOWS\system32\midimap.dll', No symbols loaded.
    The thread 'Win32 Thread' (0xb2c) has exited with code 0 (0x0).


    Still no success.

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

    Default Re: mysql 5 connection

    Did you restart Visual Studio after modifying PATH? It needs to be restarted in order for it to pick the new environment.
    J-P Nurmi

  15. #14
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    Yes, I had to do it with Dependency Walker too.

    Renan

  16. #15
    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: mysql 5 connection

    try to rebuild mysql plugin.

  17. #16
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    Im using a commercial version of QT, shouldn't it be ready to use?

    Renan

  18. #17
    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: mysql 5 connection

    please, show content of configure.cache

  19. #18
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    where is this file?

    Renan

  20. #19
    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: mysql 5 connection

    in root of QTDIR folder, i.e. C:\Qt-4.4.0\configure.cache

  21. #20
    Join Date
    Aug 2008
    Location
    Porto Alegre
    Posts
    65
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mysql 5 connection

    I haven't found this file, but I found this one:

    .qmake.cache

    QMAKE_QT_VERSION_OVERRIDE = 4
    OBJECTS_DIR = tmp\obj\debug_shared
    MOC_DIR = tmp\moc\debug_shared
    RCC_DIR = tmp\rcc\debug_shared
    sql-plugins += odbc sqlite
    styles += windows plastique cleanlooks windowsxp windowsvista motif cde
    imageformat-plugins += gif tiff jpeg
    CONFIG += dist-config large-config medium-config minimal-config small-config full-config build_all debug incremental create_prl link_prl depend_includepath QTDIR_build
    QT_BUILD_PARTS = libs tools examples demos docs
    QMAKESPEC = C:\utils\Qt\4.4.0\mkspecs\win32-msvc2003
    ARCH = windows
    QT_BUILD_TREE = C:\utils\Qt\4.4.0
    QT_SOURCE_TREE = C:\utils\Qt\4.4.0
    DEFINES *= QT_EDITION=QT_EDITION_DESKTOP
    QMAKE_MOC = $$QT_BUILD_TREE\bin\moc.exe
    QMAKE_UIC = $$QT_BUILD_TREE\bin\uic.exe
    QMAKE_UIC3 = $$QT_BUILD_TREE\bin\uic3.exe
    QMAKE_RCC = $$QT_BUILD_TREE\bin\rcc.exe
    QMAKE_DUMPCPP = $$QT_BUILD_TREE\bin\dumpcpp.exe
    QMAKE_INCDIR_QT = $$QT_BUILD_TREE\include
    QMAKE_LIBDIR_QT = $$QT_BUILD_TREE\lib

Similar Threads

  1. MySQL currency storage problem
    By MarkoSan in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2008, 10:04
  2. mysql configuration with qt
    By bala in forum Installation and Deployment
    Replies: 3
    Last Post: 6th November 2007, 12:02
  3. qt4.3.1 mysql problem
    By twells55555 in forum Qt Programming
    Replies: 5
    Last Post: 8th October 2007, 22:26
  4. MySQL starting problem
    By shamik in forum General Discussion
    Replies: 5
    Last Post: 25th April 2007, 08:20
  5. Qt 4.1.4 & Mysql 5 on Linux x64
    By bothapn in forum Installation and Deployment
    Replies: 7
    Last Post: 4th August 2006, 14:23

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.