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. Slow database connection
Qt 6.11 is out! See what's new in the release blog

Slow database connection

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.4k Views 2 Watching
  • 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.
  • G Offline
    G Offline
    great88
    wrote on last edited by
    #1

    I connect to my database using following code :
    @
    db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("server-name");
    db.setPort(3306);
    db.setDatabaseName("database_name");
    db.setUserName("root");
    db.setPassword("password");
    if (!db.open())
    {

    }
    @

    This seems to work fine when my application is running on local machine
    where the MySql database is running . But when I run the application
    remotely , there is some considerable delay connecting
    to the database . It seems like either the drivers are taking too long to load
    or MySql handles remote connections too slowly .

    Is this a driver issue or is it MySql ? Anybody have a similar problem ?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      Just place the time information between all the instruction & measure the same. One suspect I have is DNS resolution for your server name. Try giving the IP address directly. See how it goes.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NickF15
        wrote on last edited by
        #3

        Any solution found for your problem? if yes can you share it please...

        1 Reply Last reply
        0

        • Login

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