Results 1 to 2 of 2

Thread: QT mysql connectivity issue on other than default port

  1. #1
    Join Date
    Jun 2010
    Posts
    97
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QT mysql connectivity issue on other than default port

    Hi,

    I have QT mysql connectivity issue.

    I have created one docker instance where I have installed mysql. This mysql instance is running
    on port 6603 and not a regular port of 3306.
    This port is open and is accessible from outside as well. Now I am connecting to this mysql instance
    from all other applications which is not built using QT, like I am able to connect using node js or
    any other 3rd party mysql editor. This means there is no connectivity issue.
    But when I try to connect to this server using QSqlDatabase, it is either not connecting or says access denied.
    However, if I change the above server port from 6603 to default 3306, QT application is able to connect.
    Not getting where the things are going wrong. I have used below code of QT.

    Qt Code:
    1. QJsonObject jo = getConnectionDetails(); // getConnectionDetails has all values of actual connections.
    2. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL",jo.value("conn_name").toString());
    3. db.setHostName(jo.value("hostname").toString());
    4. db.setDatabaseName(jo.value("dbname").toString());
    5. db.setUserName(jo.value("username").toString());
    6. db.setPassword(jo.value("password").toString());
    7. db.setPort(jo.value("port").toInt());
    8. if (!db.open()){
    9. error = db.lastError().databaseText();
    10. qDebug() << "Connection error: " + error;
    11. return false;
    12. }
    13. return true;
    To copy to clipboard, switch view to plain text mode 

    Above code is part of connector function.
    Please suggest why this happening?

    Cheers

    Manish

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    545
    Thanked 84 Times in 79 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT mysql connectivity issue on other than default port

    Wouldn't it be easier to answer the questions in the other forum before posting it here where due to the lack of the answers the same questions arise?

Similar Threads

  1. Replies: 4
    Last Post: 5th December 2011, 17:54
  2. MYSQL Qt connectivity??
    By Gokulnathvc in forum Newbie
    Replies: 13
    Last Post: 29th July 2011, 13:38
  3. Fetch default values from MySQL?
    By arimaniac in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2011, 20:36
  4. Replies: 3
    Last Post: 11th December 2010, 20:28
  5. QSqlDatabase default MySQL unix socket path
    By daggilli in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2008, 19:55

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.