Results 1 to 8 of 8

Thread: Problem compiling QDB2 SQL driver

  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem compiling QDB2 SQL driver

    I recently installed IBM DB2 ver 9.7 and the development library.
    I went to the Qt src/plugins/sqldrivers/db2 directory and modified the pro file to get all the compile errors I could out:

    Qt Code:
    1. TARGET = qsqldb2
    2.  
    3. HEADERS = ../../../sql/drivers/db2/qsql_db2.h
    4. SOURCES = main.cpp \
    5. ../../../sql/drivers/db2/qsql_db2.cpp
    6. INCLUDEPATH+=/opt/ibm/db2/V9.7/include
    7. LIBS+=-L/opt/ibm/db2/V9.7/lib32 -ldb2
    8.  
    9. # unix:!contains( LIBS, .*db2.* ):LIBS *= -ldb2
    10. # win32:!contains( LIBS, .*db2.* ):LIBS *= -ldb2cli
    11.  
    12. include(../qsqldriverbase.pri)
    To copy to clipboard, switch view to plain text mode 

    I get 2 warnings:

    /home/vince/Downloads/Qt/qt-x11-opensource-src-4.5.2/src/plugins/sqldrivers/db2/../../../sql/drivers/db2/qsql_db2.cpp:1479: warning: enumeration value ‘FinishQuery’ not handled in switch
    /home/vince/Downloads/Qt/qt-x11-opensource-src-4.5.2/src/plugins/sqldrivers/db2/../../../sql/drivers/db2/qsql_db2.cpp:299: warning: ‘double qGetDoubleData(SQLHANDLE, int, bool&)’ defined but not used
    Deciding to ignore for now, I copied the library file to the /usr/share/qt4/plugins/sqldrivers directory but my app doesn't load the driver and the output indicates that the QDB2 driver isn't amongst the available drivers.

    Anyone know what the problem is ?
    Could the warnings stop the driver from loading ?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problem compiling QDB2 SQL driver

    Quote Originally Posted by vieraci View Post
    Anyone know what the problem is ?
    Yes, bad programmers (for the warnings)
    Could the warnings stop the driver from loading ?
    No, both warnings are harmless. You can ignore them. Why your driver is not loaded? The error must be somewhere else.

  3. #3
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem compiling QDB2 SQL driver

    Well I've discovered the driver loads ok when I invoke the app from a command prompt but not from QT Creator IDE.

  4. #4
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem compiling QDB2 SQL driver

    In fact, it appears that the db2 driver is present, but fails at db.open().

    Qt Code:
    1. if (!QSqlDatabase::drivers().contains("QDB2"))
    2. {
    3. QMessageBox::critical(0, "Unable to load database", "This application needs the QDB2 driver");
    4. return -1;
    5. }
    6.  
    7. QSqlDatabase db = QSqlDatabase::addDatabase("QDB2");
    8. db.setHostName("host");
    9. db.setDatabaseName("myDB");
    10. db.setUserName("me");
    11. db.setPassword("pwd");
    12. if (! db.open())
    13. {
    14. // db fails to open !!
    15. }
    To copy to clipboard, switch view to plain text mode 

    This is most annoying as I can't debug the rest of the app from within the IDE

  5. #5
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem compiling QDB2 SQL driver

    Quote Originally Posted by vieraci View Post
    Well I've discovered the driver loads ok when I invoke the app from a command prompt but not from QT Creator IDE.
    that's probably because on the command prompt your db2 client dll can be found, not so in Qt Creator.

    Try putting the db2 client dll into your debug(or release) folder as a test.

  6. #6
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem compiling QDB2 SQL driver

    I already tried that
    Maybe I need to try to find a way to add the path in the ide ?

  7. #7
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem compiling QDB2 SQL driver

    do any of the sql examples work from within qt creator?

    There is a difference between linux/windows on where to put the libs/dlls. I think on linux, you need to put them in the project directory, not in debug/release but you probably knew that (judging by your number of posts).

    also, see if this is helpful:
    http://www.qtcentre.org/forum/f-qt-t...tor-25149.html
    Last edited by schnitzel; 18th November 2009 at 20:51.

  8. #8
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem compiling QDB2 SQL driver

    The examples use MySQL and yes, they run fine. It's a DB2 specific problem.

Similar Threads

  1. SQL and QItemDelegate problem
    By vieraci in forum Qt Programming
    Replies: 4
    Last Post: 31st May 2009, 01:07
  2. Problem compiling ibase driver
    By SteM in forum Installation and Deployment
    Replies: 12
    Last Post: 24th September 2007, 22:26
  3. Building new SQL driver
    By Pragya in forum Installation and Deployment
    Replies: 1
    Last Post: 27th June 2007, 08:46
  4. My Mysql 5 and Qt 4.2.2 Problem (Driver not loaded)
    By fengtian.we in forum Qt Programming
    Replies: 4
    Last Post: 9th February 2007, 08:11
  5. SQL problem
    By nimmyj in forum Qt Programming
    Replies: 4
    Last Post: 25th December 2006, 18:43

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.