summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/mysql/qsql_mysql.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2014-09-03 18:37:06 -0500
committerTimothy Pearson <[email protected]>2014-09-03 18:37:06 -0500
commit7b43eed24a592feae9b6ba8fa338fb9737bf089f (patch)
tree64290972b342da11439be46b3658983151f4bec0 /src/sql/drivers/mysql/qsql_mysql.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/mysql/qsql_mysql.cpp')
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index 7cfe0a7..f1d48d4 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -504,6 +504,8 @@ bool QMYSQLDriver::open( const QString& db,
optionFlags |= CLIENT_ODBC;
else if ( opt == "CLIENT_SSL" )
optionFlags |= CLIENT_SSL;
+ else if ( opt == "MYSQL_OPT_RECONNECT" )
+ optionFlags |= MYSQL_OPT_RECONNECT;
else
qWarning( "QMYSQLDriver::open: Unknown connect option '%s'", (*it).latin1() );
}
@@ -544,6 +546,21 @@ void QMYSQLDriver::close()
}
}
+bool QMYSQLDriver::ping()
+{
+ if ( !isOpen() ) {
+ return FALSE;
+ }
+
+ if (mysql_ping( d->mysql )) {
+ return TRUE;
+ }
+ else {
+ setLastError( qMakeError("Unable to execute ping", QSqlError::Statement, d ) );
+ return FALSE;
+ }
+}
+
QSqlQuery QMYSQLDriver::createQuery() const
{
return QSqlQuery( new QMYSQLResult( this ) );