PDA

View Full Version : QMYSQL errors



ckvsoft
23rd January 2018, 20:29
Hallo


I got some failures with QMYSQL (QSQLITE will work)

My connection will be



if (dbType == "QSQLITE") {
currentConnection = QSqlDatabase::addDatabase("QSQLITE", "CN");
currentConnection.setDatabaseName(QString(dataDir + "/%1-%2.db").arg(date.year()).arg(basename));
} else if (dbType == "QMYSQL") {
QString userName = settings.value("DB_userName", "QRK").toString();
QString password = settings.value("DB_password", "").toString();
QString hostName = settings.value("DB_hostName", "localhost").toString();

currentConnection = QSqlDatabase::addDatabase("QMYSQL", "CN");
currentConnection.setHostName(hostName);
currentConnection.setUserName(userName);
currentConnection.setPassword(password);
currentConnection.setConnectOptions("MYSQL_OPT_RECONNECT=1;MYSQL_OPT_CONNECT_TIMEOUT=86 400;MYSQL_OPT_READ_TIMEOUT=60");
}

bool ok = currentConnection.open();



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.



QSqlDatabase dbc = QSqlDatabase::database("CN");
QSqlQuery query(dbc);

query.prepare("SELECT strValue FROM globals WHERE name='shopName'");
query.exec();
query.next();

name = query.value(0).toString();



thx Chris

ckvsoft
29th January 2018, 13:30
thx fixed

lg Chris