0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 17:18:10 +03:00

Connection will be restored if server is gone away or drop limereport connection

This commit is contained in:
Arin Alexander 2017-02-10 23:08:49 +03:00
parent f613400839
commit 034f254d5c
2 changed files with 12 additions and 3 deletions

View File

@ -702,6 +702,11 @@ bool DataSourceManager::initAndOpenDB(QSqlDatabase& db, ConnectionDesc& connecti
return connected;
}
bool DataSourceManager::checkConnection(QSqlDatabase& db){
QSqlQuery query("Select 1",db);
return query.first();
}
bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
{
@ -726,7 +731,10 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
db.close();
connected = initAndOpenDB(db, *connectionDesc);
} else {
connected = db.isOpen();
// connected = db.isOpen();
connected = checkConnection(db);
if (!connected)
connected = initAndOpenDB(db, *connectionDesc);
}
}

View File

@ -215,6 +215,7 @@ protected:
void setLastError(const QString& value);
void invalidateLinkedDatasources(QString datasourceName);
bool checkConnection(QSqlDatabase &db);
private slots:
void slotConnectionRenamed(const QString& oldName,const QString& newName);
void slotQueryTextChanged(const QString& queryName, const QString& queryText);