Results 1 to 7 of 7

Thread: OT : QSql - connections fail after a while.

  1. #1
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default OT : QSql - connections fail after a while.

    My program does a lot of transactions with a mysql database over short space of time. Server/Client hosts our XP.

    After a while the connections start to fail with

    DB open failed: QSqlError(2003, ""QMYSQL: Unable to connect"", ""Can't connect to MySQL server on 'localhost' (10048)"")

    My hunch is the QSqlDatabase::close() connections take some time to complete.
    "time to live" connection close time setting may fix this. But can't find.
    I've looked in Mysql global settinggs / Tcpip registrys.

    Has any one seen this before and know of a fix. Don't want to keep restarting the mysql service.

  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: OT : QSql - connections fail after a while.

    Do you have to close those connections all the time? Can't you use a persistent connection?

  3. #3
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OT : QSql - connections fail after a while.

    Can different hosts open up more than one connection on the same port?

    This was the reason why I keep closing/opening the connections - So others can access the database concurrently.

  4. #4
    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: OT : QSql - connections fail after a while.

    Quote Originally Posted by Harvey West View Post
    Can different hosts open up more than one connection on the same port?
    If you mean the target port then yes. For example your internet browser does exactly that

  5. #5
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OT : QSql - connections fail after a while.

    I can have multiple open connections provided i'm not from the same client host.

    i.e I cannot connect to database if i have a connection already opened on the client host.

  6. #6
    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: OT : QSql - connections fail after a while.

    Then you have the database set up very strictly. Just don't close the connection and reuse it. If you don't use multiple threads, it'll be fine. If you do use multiple threads, then simply dedicate one thread to operate on the database and pass all database requests from other threads to the dedicated one.

  7. #7
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OT : QSql - connections fail after a while.

    Cheers wysota. This makes much more sense now.

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.