07-03-2013 08:51 AM
have small messaging application where each message data is stored in SQLite Database.
We update database on every send/receive message as well as simultaneously update UI with database attribute.
While doing this we are facing a CRASH.
After trying lots of things we solve problem using static variable of database
QSqlDatabase MyDatabase::messagDb= QSqlDatabase::addDatabase("QSQLITE", "message");
we never close database connection, and do all operation on database in single theread that is synchronous. In UI thread.
This thing is work fine except we see sufficient amount of lag in our application because of database operation in UI Thread.
Is there a way we can do multiple thread or implement database connection pool ?
that can achieve both synchronous and asynchronous database operations.
07-03-2013 09:01 AM
07-04-2013 02:45 AM
Thanks for reply
I tried that before it before.
What happen when I use SqlConnection
its ok to storing received message or task that not need to be done in asynchronous but when i some operation like before saving message i have to check user status in sychronous way meanwhile if some task in running in background by SqlConnection that synchronous operation give sqlite busy error and app crashes.
07-04-2013 07:26 AM
I really advise against use synchronous database operation. Just start the operation and wait for the proper signal to signal that the data is ready.