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:
Code:
TARGET = qsqldb2
HEADERS = ../../../sql/drivers/db2/qsql_db2.h
SOURCES = main.cpp \
../../../sql/drivers/db2/qsql_db2.cpp
INCLUDEPATH+=/opt/ibm/db2/V9.7/include
LIBS+=-L/opt/ibm/db2/V9.7/lib32 -ldb2
# unix:!contains( LIBS, .*db2.* ):LIBS *= -ldb2
# win32:!contains( LIBS, .*db2.* ):LIBS *= -ldb2cli
include(../qsqldriverbase.pri)
I get 2 warnings:
Quote:
/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 ?
Re: Problem compiling QDB2 SQL driver
Quote:
Originally Posted by
vieraci
Anyone know what the problem is ?
Yes, bad programmers :D (for the warnings)
Quote:
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.
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. :confused:
Re: Problem compiling QDB2 SQL driver
In fact, it appears that the db2 driver is present, but fails at db.open().
Code:
{
QMessageBox::critical(0,
"Unable to load database",
"This application needs the QDB2 driver");
return -1;
}
db.setHostName("host");
db.setDatabaseName("myDB");
db.setUserName("me");
db.setPassword("pwd");
if (! db.open())
{
// db fails to open !!
}
This is most annoying as I can't debug the rest of the app from within the IDE :mad:
Re: Problem compiling QDB2 SQL driver
Quote:
Originally Posted by
vieraci
Well I've discovered the driver loads ok when I invoke the app from a command prompt but not from QT Creator IDE. :confused:
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.
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 ?
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
Re: Problem compiling QDB2 SQL driver
The examples use MySQL and yes, they run fine. It's a DB2 specific problem.