Results 1 to 2 of 2

Thread: QMYSQL errors

  1. #1
    Join Date
    Feb 2016
    Posts
    21
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QMYSQL errors

    Hallo


    I got some failures with QMYSQL (QSQLITE will work)

    My connection will be

    Qt Code:
    1. if (dbType == "QSQLITE") {
    2. currentConnection = QSqlDatabase::addDatabase("QSQLITE", "CN");
    3. currentConnection.setDatabaseName(QString(dataDir + "/%1-%2.db").arg(date.year()).arg(basename));
    4. } else if (dbType == "QMYSQL") {
    5. QString userName = settings.value("DB_userName", "QRK").toString();
    6. QString password = settings.value("DB_password", "").toString();
    7. QString hostName = settings.value("DB_hostName", "localhost").toString();
    8.  
    9. currentConnection = QSqlDatabase::addDatabase("QMYSQL", "CN");
    10. currentConnection.setHostName(hostName);
    11. currentConnection.setUserName(userName);
    12. currentConnection.setPassword(password);
    13. currentConnection.setConnectOptions("MYSQL_OPT_RECONNECT=1;MYSQL_OPT_CONNECT_TIMEOUT=86400;MYSQL_OPT_READ_TIMEOUT=60");
    14. }
    15.  
    16. bool ok = currentConnection.open();
    To copy to clipboard, switch view to plain text mode 

    When i was connected i got, but not allways a SIGSEGV. When i remove the connection options i got "Lost connection to MySQL server during query"
    no matter if MySQL Server is localhost or any Server on the Internet.

    Yes, i search but found no solution. What can i do false?

    OS: Linux Ubuntu (16.04 and 17.10) Server MariaDB from the Ubuntu Package

    A Simply Query which returns one record and the Database holds max. 10 Entries.

    Qt Code:
    1. QSqlDatabase dbc = QSqlDatabase::database("CN");
    2. QSqlQuery query(dbc);
    3.  
    4. query.prepare("SELECT strValue FROM globals WHERE name='shopName'");
    5. query.exec();
    6. query.next();
    7.  
    8. name = query.value(0).toString();
    To copy to clipboard, switch view to plain text mode 


    thx Chris

  2. #2
    Join Date
    Feb 2016
    Posts
    21
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QMYSQL errors

    thx fixed

    lg Chris

Similar Threads

  1. QMYSQL available but not loaded ?
    By davidovv in forum Installation and Deployment
    Replies: 0
    Last Post: 11th December 2012, 20:34
  2. Qmysql
    By arjoshi in forum Installation and Deployment
    Replies: 6
    Last Post: 1st April 2011, 17:21
  3. Qmysql
    By babygal in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2010, 08:14
  4. I want to use QMYSQL
    By gt.beta2 in forum Qt Programming
    Replies: 15
    Last Post: 15th April 2009, 17:08
  5. another qmysql error
    By bluesguy82 in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 16:07

Tags for this Thread

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.