Important: Please read the Qt Code of Conduct -

DB2 driver for centos8 built with Qt 5.9.8 not working .

  • I have to port a CentOS 6 application to CentoOS 8.

    I was able to compile the qt4 application in qt5 with some changes in source.
    Later I built the driver for DB2 v11 and tried to run tehe application.
    But it throws some wierd error in chinese and I am not able to figure out the issue.
    Can someone give a hint how I can find the root cause ?

    ![alt text](c08fc2f4-6952-4742-a9bb-c6a6d305c005-image.png image url)

    There is no issue with DB conenction/credentials as the same is working fine if I use qt4 db2 driver , it connects to DB but the GUI is mising some images/themes.

  • Lifetime Qt Champion

    @Gurubg If I understand you correctly you do not speak Chinese, right? Me neither :-) Did you try to use Google Translate to translate the content of the message box?

  • @jsulm Ofcourse , the first thing I did was to try to translate the message in google. But even google can't translate it . So I thought I should seek help in this forum.

  • Lifetime Qt Champion

    @Gurubg You can try to search for the message text in the source code of that app to see when it is shown.

  • @jsulm its not from the app, its the sqlerror from QSqlDatabase::lastError().text() . code is something like below
    m_sampledb = QSqlDatabase::addDatabase(strtargetstr.toStdString().c_str());
    m_sampledb.setHostName ( ().constData());
    m_sampledb.setDatabaseName (strdbnamestr.toStdString().c_str());
    m_sampledb.setUserName (strusernamestr.toStdString().c_str());
    m_sampledb.setPassword (strpasswordstr.toStdString().c_str());
    m_sampledb.setPort (;

    if (! {
    QMessageBox::critical (0, QObject::tr ("Database Error"), m_sampledb.lastError().text ());
    return false;
    --> This used to work perfectly in CentOS 6

  • Lifetime Qt Champion

    @Gurubg So it fails to open db, but since I don't understand the message text I can't tell why.

  • Is there any issue with QT 5.11 and DB2 V11.5 ? This connection issue is hard nut to crack !

  • Lifetime Qt Champion

    Can you please tell us what the error message says? Best is to start it as en_US instead your locale. And why all this useless QString::toStdString().c_str() stuff in the connection setup code?

  • @Christian-Ehrlicher said in DB2 driver for centos8 built with Qt 5.9.8 not working .:


    I was able to print the error from qsql_db2.cpp ( I added printf) . [IBM][CLI Driver] SQL1024N A database connection does not exist. SQLSTATE=08003

  • I found the issue , the problem was with db2/qsql_db2.cpp file which calls SQLDriverConnect with qToTChar(connQStr) param.
    I enabled db trace and checked DB2 received only one char instead of the full connection string.
    I changed it to (unsigned char ) connQStr.toLatin1().data()* and it worked.
    Now the problem is the queries called from exec() function with below error

    [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N  An unexpected token "END-OF-STATEMENT" was found following "s".  Expected tokens may include:  "JOIN <joined_table>".  SQLSTATE=42601

    Is QT5 by default UNICODE enabled ? how do I disable it ?

Log in to reply