Results 1 to 9 of 9

Thread: Accessing xampp mysql database

  1. #1
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Accessing xampp mysql database

    Hi folks,

    here is what I want to do:

    I'running an apache mysql server with xampp on a windows vista 32bit machine (would like to do this with linux, but have to do it with vista...) and want to access a database through the QSqlTableModel in my xampp/mysql directory.
    The dev packs(lib and header) for mysql is installed.

    Qt Version is 4.4.3 and i tried to install the mysql plugin with the following command in the Qt command prompt: "c:\Qt\4.4.3\src\plugins\sqldrivers\mysql>qmak e "INCLUDEPATH+=C:\xampp\MySQL\incl
    ude" "LIBS+=C:\xampp\MySQL\lib\opt\libmysql.lib" mysql.pro"
    This command works, but when i do a "make" afterwards, i get lots of errors with 'undefined references to 'mysql_query@8'' and exit status 1.

    Helpful:
    http://doc.trolltech.com/4.4/sql-dri...gin-on-windows and
    http://wiki.qtcentre.org/index.php?t...ws_using_MinGW

    Installing latest mingw and using reimp should work.

    What did i do wrong?
    Does the mysql server has to be running when installing? - i guess no -
    Is the process for installing the mysql plugin similiar for Qt4.5?
    Do I need to have the mysql running as a service in my xampp control center, when I want to access the database?
    Has anybody experience with this issue?

    Any help would be a peach

    Best Regards
    --synack
    Last edited by synack; 9th March 2009 at 12:31. Reason: spelling

  2. #2
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Question Re: Accessing xampp mysql database

    Hi,

    in context to this article

    http://wiki.qtcentre.org/index.php?t...ws_using_MinGW

    I need a little bit help please.

    The scenario is the mentioned above. I did steps 1-4 how described in the wiki article and no errors.
    At step 5 when doing 'make', I get these errors:

    <pre>
    C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winbase.h:1676: error:
    declaration of C function `LONG InterlockedIncrement(volatile LONG*)' conflicts
    with
    ../../../../include/QtCore/../../src/corelib/arch/qatomic_windows.h:388: error:
    previous declaration `long int InterlockedIncrement(long int*)' here
    mingw32-make[1]: *** [tmp/obj/release_shared/main.o] Error 1
    mingw32-make[1]: Leaving directory `c:/Qt/4.4.3/src/plugins/sqldrivers/mysql'
    mingw32-make: *** [release-all] Error 2
    </pre>

    I really have no glue that i'm doing wrong.
    MinGW works, the lib and header for mysql is installed, reimp works, liblibmysql.a has been created, so if you have any suggestions post them.

    Regards
    --synlag

  3. #3
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing xampp mysql database

    Perhaps this an issue for the bug tracker.

    Here's that really simple code, i want to run:

    Qt Code:
    1. #include <QtGui>
    2. #include <QtSql>
    3. #include <QtDebug>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8.  
    9. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    10.  
    11. db.setHostName("localhost");
    12. db.setDatabaseName("c5testdb");
    13. db.setUserName("root");
    14. db.setPassword("");
    15.  
    16. if(!db.open()) {
    17. QSqlError err = db.lastError();
    18. QMessageBox::information(0, QObject::tr("Fehler!"), err.text());
    19. return 1;
    20. }
    21.  
    22. QTableView tableView;
    23.  
    24. model.setTable("users");
    25. model.select();
    26. model.setEditStrategy(QSqlTableModel::OnFieldChange);
    27. tableView.setModel(&model);
    28. tableView.setWindowTitle("SQL-Demonstration");
    29. tableView.show();
    30. return a.exec();
    31. }
    To copy to clipboard, switch view to plain text mode 


  4. #4
    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: Accessing xampp mysql database

    create QSqlTableModel model; on a heap.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing xampp mysql database

    Quote Originally Posted by spirit View Post
    create QSqlTableModel model; on a heap.


    Did you read the two posts above? I think no you didn't.
    For this example it makes no difference if the model is on heap or stack.

  6. #6
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing xampp mysql database

    Does anyone has experience setting up a mysql connection with Qt4.5 ?

  7. #7
    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: Accessing xampp mysql database

    yup, works fine for me.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #8
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing xampp mysql database

    Ok, it would be nice if you could explain what is the difference between installing mysql on a windows machine to the previous Qt version, if there is any.
    I did it like described in this article
    http://wiki.qtcentre.org/index.php?t...ws_using_MinGW
    but it does not work for Qt4.5

    Thx so far

  9. #9
    Join Date
    Feb 2009
    Location
    Nuremberg, Germany
    Posts
    13
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing xampp mysql database

    wimblows, so i'm back on my lamp now...
    works fine so far, and when i've time i'll maybe look into it, making the app work for win

Similar Threads

  1. Putting and getting images from MySQL database?
    By allensr in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2007, 21:47
  2. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  3. Replies: 7
    Last Post: 12th August 2006, 15:11
  4. Issues regarding QMySql drivers and mysql database
    By bera82 in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2006, 17:50
  5. Replies: 8
    Last Post: 7th March 2006, 13:40

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.