summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/psql/qsql_psql.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-09-03 18:37:06 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-09-03 18:37:06 -0500
commit7b43eed24a592feae9b6ba8fa338fb9737bf089f (patch)
tree64290972b342da11439be46b3658983151f4bec0 /src/sql/drivers/psql/qsql_psql.cpp
parent4de369738339e5755968b1bcbae0baa515917386 (diff)
downloadqt3-7b43eed24a592feae9b6ba8fa338fb9737bf089f.tar.gz
qt3-7b43eed24a592feae9b6ba8fa338fb9737bf089f.zip
Add ability to set reconnect flag on MySQL connections
Add database server ping method to SQL classes
Diffstat (limited to 'src/sql/drivers/psql/qsql_psql.cpp')
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 7fe1a91..9d028c0 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -679,6 +679,29 @@ void QPSQLDriver::close()
}
}
+bool QPSQLDriver::ping()
+{
+ if ( !isOpen() ) {
+ return FALSE;
+ }
+
+ PGresult *res = NULL;
+
+ // Send ping
+ res = PQexec( d->connection, "" );
+ PQclear(res);
+
+ // Check connection status
+ if ( PQstatus( d->connection ) != CONNECTION_OK ) {
+ PQreset( d->connection );
+ if ( PQstatus( d->connection ) != CONNECTION_OK ) {
+ setLastError( qMakeError("Unable to execute ping", QSqlError::Statement, d ) );
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
QSqlQuery QPSQLDriver::createQuery() const
{
return QSqlQuery( new QPSQLResult( this, d ) );