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. Use an IPv6 as host with QSqlDatabase (Qt-4.8)
Forum Updated to NodeBB v4.3 + New Features

Use an IPv6 as host with QSqlDatabase (Qt-4.8)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 995 Views 1 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.
  • joselebonJ Offline
    joselebonJ Offline
    joselebon
    wrote on last edited by SGaist
    #1

    Hello everyone,

    I try to connect to a mysql database with the IPv6 address of the server.

    It seems that setHostname() method doesn't support an IPv6 argument...

    How can I do that ?

    Thank you

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you show your database connection code ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • joselebonJ Offline
        joselebonJ Offline
        joselebon
        wrote on last edited by
        #3

        Hello,

        The connection to the database works with an IPv4 but I need to use an IPv6.

        _lpdb->open() return false when I use an IPv6.

        Here is my code:

                    QString _qstr_dbHostAddress = "fd02:0000:0000:0000:1030:00ff:fe00:0002";
                    *_lpdb = QSqlDatabase::addDatabase("QMYSQL");
                    _lpdb->setHostName(_qstr_dbHostAddress);
                    _lpdb->setDatabaseName(_qstr_dbName);
                    _lpdb->setUserName(_qstr_dbLogin);
                    _lpdb->setPassword(_qstr_dbPassword);
        
                    // Manage database connection
                    if(_lpdb->open())
                    {
                        // Refresh data of NDA Thread
                        qDebug() << "NDAThread::run : connection to database success";
                        getDataFromDataBase();
                        // Close the database connection
                        _lpdb->close();
                    }
                    else
                    {
                        qDebug()<< "NDAThread::run : cannot connect to database";
                        //qDebug() << QSqlDatabase::drivers();
                    }
        

        Thank you

        1 Reply Last reply
        0
        • joselebonJ Offline
          joselebonJ Offline
          joselebon
          wrote on last edited by joselebon
          #4

          I found the problem!

          It is on mysql server not the client.

          I have enabled the connection for the clients with IPv4 and IPv6 with a modification in /etc/mysql/my.cnf

          // the parameter ::  enables connection from all client with an IPv4 or an IPv6 
          bind-address       =  ::
          

          There is more informations here : https://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_bind-address

          Thank you

          1 Reply Last reply
          2

          • Login

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