Unsolved QSqlDriver does not support Transactions (but everything seems to be installed)
-
Hello all,
i create a connection to a local 10.1.26-MariaDB. Im using QSqlDatabase to connect to it ... everything works fine ... i can INSERT, UPDATE, SELECT .... . But if i ask with:
QSqlDatabase db = QSqlDatabase::database(); if (!db.driver()->hasFeature(QSqlDriver::Transactions))
It returns false.
My installation is following:
- Windows 7 (64bit)
- Qt5.7.0
- MySQL Workbench 6.3 CE (i link there to the libmysql.dll)
- db setup with xampp (because of this mariadb)
I really dont get whats wrong ... searching now for 8 hours but find nothing.
Thanks for you help guys,
MrEinsA
-
Most likely is due to a restriction in the Qt code that manages the driver. what driver are you using? what are you passing to
QSqlDatabase::addDatabase
? -
Thanks for the fast reply, this is my connection code:
m_dbConnection = QSqlDatabase::addDatabase("QMYSQL"); m_dbConnection.setHostName(host); m_dbConnection.setPort(port); if (!m_dbConnection.open(user, password)) { coutFRed("::connect, %s", qPrintable(m_dbConnection.lastError().text())); return false; } coutFGreen("::connect, connection active...");
-
Hi and welcome to devnet,
What version of MySQL is your server ?
-
@SGaist
Happy new year!!!I run it with the current XAMPP on my localhost (10.1.26-MariaDB), but even with a database on my server MySQL 5.7.
-
Same to you !
Did you rebuild the Qt MySQL plugin ?
-
@SGaist
Hm nope i use the standard one directly from Qt. Is this probably a problem? -
Not necessarily. The transaction detection is effective if the client library version used to build the plugin is greater than 3.23.34. Now the question is is, are you sure the server supports it ?
-
@SGaist
Thanks for the answer ... yes im sure, i tested it in the MySQL Workbench and its running there. Hm maybe i should reinstall everything again. -
Hello all,
if i generate the transaction by myself with QSqlQuery ... it works ... but not with the functions provided by the QSqlDriver. Hmpf
-
How were you using it ?
-
@SGaist
Hi, like this:m_dbConnection.setHostName(host); m_dbConnection.setPort(port); if (!m_dbConnection.open(user, password)) { return false; } if (!m_dbConnection.driver()->hasFeature(QSqlDriver::Transactions)) { ... }
-
So basically if you don't do the check and use it, it works as expected ?
-
@SGaist
Nope ... i tested it a lot and it dont work. -
Sorry, I misunderstood you. So if you write the transaction in the SQL statement of the QSqlQuery it's working properly. Correct this time ?
-
@SGaist
Yes if i write the transaction sql syntax in the QSqlQuery by myself ... it is working correctly. -
That's not the most easy but I'd re-build the MySQL plugin to see what the check does currently.