Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does anyone have any success running mysql ODBC connector with QSqlQuery and mac osx 10.7 ?
QtWS25 Last Chance

Does anyone have any success running mysql ODBC connector with QSqlQuery and mac osx 10.7 ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil
    wrote on 6 Jul 2012, 13:47 last edited by
    #1

    My application running correctly in Linux and Windows but I have no success with Mac ocx 10.7. I use Qt Libraries 2.5 and Qt Creator 4.8.2. I tried the mysql ODBC 5.1.11 for mac osx 10.6 (Maybe is the problem). I'am able to connect to my database but query.next() return no values. I got this error :QODBC3: Unable to fetch first. I tried to set query.setForwardOnly(true). Someone has an idea

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Phil
      wrote on 7 Jul 2012, 13:35 last edited by
      #2

      Sorry Qt Creator 2.5 and libraries 4.8.2

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pcmantinker
        wrote on 7 Jul 2012, 21:41 last edited by
        #3

        Phil,

        It appears that there is a bug with query.next() using ODBC in Mac OS X. The bug report for 4.8.0 with a temporary work around is here: https://bugreports.qt-project.org/browse/QTBUG-25260

        I know that this bug still exists in 4.8.1, but I've not looked at 4.8.2's source so I can't verify. Hopefully this bug is fixed in Qt 5.0.

        I had to recompile the ODBC sql driver plugin from source making the modifications suggested in the work around in qsql_odbc.cpp in the QODBCResult::fetchNext() function on line 1043. The class file, qsql_odbc.cpp, can be found at /Users/[you]/QtSources/4.8.[x]/src/sql/drivers/odbc/qsql_odbc.cpp.

        Note: If you downloaded the source outside of Qt Creator, you'll need to browse to where you extracted the source. This applies to all paths supplied in this post.

        I commented out the conditional part, beginning on line 1033, where SQLFetchScroll is called so that it looks like this:
        @// if (d->hasSQLFetchScroll)
        // r = SQLFetchScroll(d->hStmt,
        // SQL_FETCH_NEXT,
        // 0);
        // else
        r = SQLFetch(d->hStmt);@

        Then I opened up /Users/you/QtSources/4.8.x/src/plugins/sqldrivers/odbc/odbc.pro within Qt Creator and built the source. The outputted dylibs are put in the sqldrivers directory in their respective release and debug folders.

        When building the plugin, it's very important that you use the correct version of Qt to build. For instance, if you're targeting Qt 4.8.2, make sure you have Qt 4.8.2 configured in your Qt versions from Qt Creator.

        After you build the ODBC plugin, you're ready to replace your Qt installation's dylibs with the newly built dylibs. First, make a back up of libqsqlodbc.dylib and libqsqlodbc_debug.dylib from your Qt installation. This is typically in /Users/you/QtSDK/Desktop/Qt/4.8.x/gcc/plugins/sqldrivers. Then you can overwrite your Qt installation's dylibs.

        Now you should be able to get results from query.next() within your application.

        1 Reply Last reply
        0

        1/3

        6 Jul 2012, 13:47

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved