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

Thread: connecting to MySQL through it's API

  1. #1
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question connecting to MySQL through it's API

    I'm now trying to connect to my app to MySQL using mysql.h from MySQL 4.1.... as I just can't make the damn plugin... somewhere theres a post explaining the plugin stuff..

    The thing now is that after I made the connection I retrieve the table list as this:

    Qt Code:
    1. .......
    2. #include <mysql.h>
    3. ....
    4. ..
    5. MYSQL_RES *res;
    6. ...
    7. ..
    8.  
    9. QStringList tablas()
    10. {
    11. if (!res=mysql_list_tables( &mysql, NULL ))
    12. {
    13. QMessageBox::warning(0,"No se pudo obtener la lista de tablas", mysql_error( &mysql ));
    14. }
    15. QStringList listaTablas = res->toStringList;
    16. //convert MYSQL_RES to QSTRINGLIST ???
    17. for ( QStringList::Iterator it = listaTablas.begin(); it != listaTablas.end(); ++it ) {
    18. qWarning(*it + "\n");
    19. }
    20. //muestra en consola la lista de tablas de la base de datos a la que se conecto
    21.  
    22. return listaTablas;
    23. }
    To copy to clipboard, switch view to plain text mode 

    so the question is..... tararraaarrataaan.
    how do i get res to fill a QStringList?

    I've tryed casting:
    Qt Code:
    1. QStringList listaTablas = (QStringList)res;
    To copy to clipboard, switch view to plain text mode 

    Dumbass way:
    Qt Code:
    1. QStringList listaTablas = res;
    To copy to clipboard, switch view to plain text mode 

    and DumbAss2 xD as there is no member... etc
    error: 'struct st_mysql_res' has no member named 'toStringList
    Qt Code:
    1. QStringList listaTablas = res->toStringList;
    To copy to clipboard, switch view to plain text mode 


    Any ideas?
    the final idea is to fill a qcombobox with the QStringList with the table list

    Qt Code:
    1. CB_Tablas->insertStringList(tablas());
    To copy to clipboard, switch view to plain text mode 

    as you can see the function named tablas returns a QStringList that contains or should contain the table list from the database

    please don't tellme to use qdatabase.h as that's now not an option
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  2. #2
    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: connecting to MySQL through it's API

    You have to process the result row by row and extract the data yourself... You can take a look at QMYSQL plugin to see how it does it. Oh, and don't give up compiling that plugin To be honest I have never had problems with that... Maybe you should try one more time? You can take a look ath the FAQ, maybe it'll help you.

  3. #3
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: connecting to MySQL through it's API

    jajja I finally made de damn plugin but I'm still geting ths Driver not Loaded shh..
    I'm now running:
    Qt Code:
    1. configure -plugin-sql-mysql -I d:\mysql\include -L d:\mysql\lib\opt
    To copy to clipboard, switch view to plain text mode 

    if that doesn't work... I finnished with the damn plugin...

    And I'm looking to the code on the main.cpp from the mysql plugin and nothing so I'm looking on the qsql_mysql.cpp and well no ideas yet

    ... jejejej wait a second I think I got the idea xD... :$ as you can tell i'm working on real time XD

    I realy hope the plugin work.... I would like to keep it qt and not doing a mixed ..... thing..
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  4. #4
    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: connecting to MySQL through it's API

    Do you use Qt3 or Qt4?

  5. #5
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: connecting to MySQL through it's API

    on this case. I'm working on Qt 4.1.2 as I need to make the plugin for an app which needs to run on windows... so everything I made on linux and works with the Qt 3.1.2 on linux has to run on wnidows compiled and ported to Qt 4.1.2 the ap and the porting works perfectly.. I just have to modify de conection... change the pointer for a variable.. changing the '->' for '.' etc.. and I have to add the #include <qsqlerror.h> but it works without problems excepet for the "Driver not Loaded"...
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    it works without problems excepet for the "Driver not Loaded"...
    Check with Dependency Walker if your application and the plugin can find all DLLs they need. If there is a missing DLL, find it and place in the same directory as the executable.

  7. #7
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: connecting to MySQL through it's API

    I ran DependencyWalker on my app's exe and it tells me that couldn't find MSJAVA.DLL

    java?
    I don't remember have used java so... ?

    but well..
    on the other side.. I'm now worried about how to populate a qdatatable using the MySQL API ... mysql.h etc etc
    I made a conection and populated a qcombobox with the tables from the database..
    so now I'm trying to populate a qdatatable with the qsqlcursor... but I guess I'm not able to use it as the connection is made through the MySQL API not by qt.
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  8. #8
    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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    I ran DependencyWalker on my app's exe and it tells me that couldn't find MSJAVA.DLL
    You can safely ignore msjava.dll. Are there any other missing DLLs (especially for the plugin)?

  9. #9
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: connecting to MySQL through it's API

    it tells me that the libmysql.dll is missing so I putted it on the same folder as the exe and the qsqlmysql.dll and there's still Driver not Loaded message

    and the other way using a MySQL API connection works on linux but on windows at compilling time... it just tells me errors on mysql_com.h and that a SOCKET is created without a type

    ¬¬ Qt hates me...
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  10. #10
    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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    it tells me that the libmysql.dll is missing so I putted it on the same folder as the exe and the qsqlmysql.dll and there's still Driver not Loaded message
    Do I understand you correctly that you have placed the plugin and the executable in the same directory?

  11. #11
    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: connecting to MySQL through it's API

    qsqlmysql.dll should be in "sqldrivers/" subdirectory.

  12. #12
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: connecting to MySQL through it's API

    yeap there it is...
    and also in the release folder and in the source code dierctory... you know the one where main.cpp conexion.cpp and all cpps and hs files are


    but.. well so the driver it's giving trouble so... another aproach is connecting directly with the MySQL API ... any ideas there? like.. why is not working in windows?

    (I added LIS -Ld:\mysql... -lmysql.. and INCPATH -I d:\m....\niclude.. to the Makefiles)

    I retrieve the table list to a combobox but how to fill a qdatatable with the table selected from MySQL? as it uses a qsqlcursor to get filled... how do I fill the cursor or the table directly?

    Help PleasEEEE
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  13. #13
    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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    but.. well so the driver it's giving trouble so... another aproach is connecting directly with the MySQL API ...
    If you can't make the plugin work, then try compiling it into the Qt (use -qt-sql-mysql instead -plugin-sql-mysql).

  14. #14
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: connecting to MySQL through it's API

    In the case that the configure -qt-sql-mysql works
    what would be the diference?.. I'm now compilling with make after the configure...
    after comnpilling my app in the case it works.. how should I pack my app to work on other windows whithout the Qt 4.1.2 installed?
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  15. #15
    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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    In the case that the configure -qt-sql-mysql works
    what would be the diference?..
    You won't have a separate DLL with the plugin. If it won't work, at least you will know why.

    Quote Originally Posted by Philip_Anselmo
    how should I pack my app to work on other windows whithout the Qt 4.1.2 installed?
    The same way, only without the qsqlmysql.dll file.

  16. The following user says thank you to jacek for this useful post:

    Philip_Anselmo (24th May 2006)

  17. #16
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: connecting to MySQL through it's API

    I just get errors... the same that i got with the plugin
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  18. #17
    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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    I just get errors... the same that i got with the plugin
    What commands did you issue? Could you post the exact error message?

  19. #18
    Join Date
    Apr 2006
    Posts
    40
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: connecting to MySQL through it's API

    I just did exactly this:

    Qt Code:
    1. configure -qt-sql-mysql -I d:\mysql\include -L d:\mysql\lib\opt -l libmysql
    To copy to clipboard, switch view to plain text mode 

    and there were some errors that now I can't remember.. so I guess isn't of too much help unless I type the command on a wrong way

    but the includes from mysql and the libs are there where i told the configure to look for...
    the libmysql.lib libmysql.a and libmysql.dll
    the libmysql.a was made acording to the manual on other posts..
    I posted the lines I used to make it on qtforum and them has been referenced to a lot of people who used them and get the plugins to work and once I used them too and it worked but not now
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  20. #19
    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: connecting to MySQL through it's API

    Unfortunately we can't help without knowing what the errors are

  21. #20
    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: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    I just did exactly this:[...]
    IMO it should be:
    Qt Code:
    1. configure -qt-sql-mysql -Id:\mysql\include -Ld:\mysql\lib\opt
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 21st March 2006, 12:54
  2. mySql Result Datatype issues!!!
    By bera82 in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2006, 10:26
  3. issues compiling Qt4.1 with mysql
    By patcito in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2006, 22:41
  4. Error connecting to MySQL
    By probine in forum Qt Programming
    Replies: 20
    Last Post: 23rd February 2006, 23:13
  5. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

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.