Results 1 to 8 of 8

Thread: SQL-Module

  1. #1
    Join Date
    Jan 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default SQL-Module

    I need access to a MySQL-Database in one of my Qt 4.0.0 programmes. I got a message: "Driver not loaded, Driver not loaded", when I tried the following code:

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName("localhost");
    3. db.setDatabaseName("testdb");
    4. db.setUserName("root");
    5. db.setPassword("");
    6. bool ok = db.open();
    7. if(ok)setText("it works");
    8. else
    9. setText(db.lastError().text());
    To copy to clipboard, switch view to plain text mode 

    In the docs, it says:
    "
    You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MYSQL):

    cd %QTDIR%\src\plugins\sqldrivers\mysql
    qmake -o Makefile "INCLUDEPATH+=C:\MYSQL\INCLUDE" "LIBS+=C:\MYSQL\LIB\OPT\LIBMYSQL.LIB" mysql.pro
    nmake
    "
    I have never installed any MySQL and I don't understand why I have to do this. After all, I don't necessarily want to access a database on my computer, it could also be on a remote computer where MySQL is installed. So I think I must have got something wrong. Can you tell me what to do?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: SQL-Module

    Its not wrong. You dont must install MySql server on localhost as you think
    You must do qmake,nmake for build MySql driver, what give access you to MySql database.

  3. #3
    Join Date
    Jan 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SQL-Module

    Ok, now I've installed MySQL 5.0. All the files can now be found on my computer. I ran:
    Qt Code:
    1. C:\Qt\4.0.0\src\plugins\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=C:\Prog
    2. ramme\MySQL\MySQLServer5.0\include" "LIBS+=C:\Programme\MySQL\MySQLServer5.0\lib
    3. \opt\LIBMYSQL.LIB" mysql.pro
    To copy to clipboard, switch view to plain text mode 

    And I got the mistake that mysql.h could not be found. So I copied all the .cpp and .h files to C:\Qt\4.0.0\src\plugins\sqldrivers\mysql and to C:\Qt\4.0.0\plugins\sqldrivers and I changed #include <mysql.h> into #include "mysql.h" and then this worked. But I got another error-message, and I don't know how to handle it:
    Qt Code:
    1. C:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot fin
    2. d -lmysql.lib
    To copy to clipboard, switch view to plain text mode 


    What to do?
    Last edited by phil_; 21st January 2006 at 18:20.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SQL-Module

    Look into the FAQ

  5. #5
    Join Date
    Jan 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SQL-Module

    Thank you for the FAQs. According to them, I tried: 'C:\Qt\4.0.0\>configure "-qt-sqlmysql" "-IC:\Programme\MySQL\MySQLServer5.0\include\" "LC:\Programme\mysql\mysqlserver5.0\include\" '.

    Now it took ages to "Read" files etc., and after some time my windows stopped working ...
    Before trying it a second time, I wanted to ask whether this is really the proper way. I thought I must have done something wrong if I have to wait for 2 hours while my computer is working on the single command "configure ..." (see above) just to get MySQL-Access? - Doesn't this go faster?

    Thanks.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SQL-Module

    Quote Originally Posted by phil_
    I tried: 'C:\Qt\4.0.0\>configure "-qt-sqlmysql" "-IC:\Programme\MySQL\MySQLServer5.0\include\" "LC:\Programme\mysql\mysqlserver5.0\include\" '.
    Shouldn't this be:
    C:\...>configure "-qt-sql-mysql" ..."-LC:\Prog..."
    Doesn't this go faster?
    Do you have anti-virus software installed?

  7. #7
    Join Date
    Jan 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SQL-Module

    No, there is no antivirus-software. But perhaps I explain what I've done so far, perhaps something else was wrong: I downloaded and installed the mysql 5.0 package from mysql.com and installed it with the provided installer. Then I launched configure ... . Did I forget a step in between?
    Last edited by phil_; 22nd January 2006 at 17:15.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SQL-Module

    "configure" shouldn't run longer than 5-10 minutes. You can speed it up a little by passing "-fast" switch to it. It'll skip generating makefiles for examples then. Certainly it shouldn't run for two hours... What hardware do you have?

Similar Threads

  1. SQL Drivers Distribution
    By kandalf in forum Installation and Deployment
    Replies: 1
    Last Post: 12th January 2009, 10:17
  2. Qt 4.4.0 Help Module : Search not working
    By Ankitha Varsha in forum Qt Programming
    Replies: 0
    Last Post: 22nd May 2008, 09:45
  3. Font differences and how to mitigate
    By PrimeCP in forum Qt Programming
    Replies: 7
    Last Post: 23rd July 2007, 23:55
  4. Can I use the Sql Module without chanage .pro file?
    By fengtian.we in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 11:59
  5. Sql module using error (Win32)
    By blackliteon in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2006, 15:45

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.