Slow database connection



  • 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 ?



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.