Automated update from Qt3

pull/1/head
Timothy Pearson 10 years ago
parent ed5df1398e
commit d8352f9db2

@ -848,6 +848,17 @@ void TQIBaseDriver::close()
} }
} }
bool TQIBaseDriver::ping()
{
if ( !isOpen() ) {
return FALSE;
}
// FIXME
// Implement ping if available
return TRUE;
}
TQSqlQuery TQIBaseDriver::createQuery() const TQSqlQuery TQIBaseDriver::createQuery() const
{ {
return TQSqlQuery(new TQIBaseResult(this)); return TQSqlQuery(new TQIBaseResult(this));

@ -94,6 +94,7 @@ public:
const TQString & host, const TQString & host,
int port ) { return open (db, user, password, host, port, TQString()); } int port ) { return open (db, user, password, host, port, TQString()); }
void close(); void close();
bool ping();
TQSqlQuery createQuery() const; TQSqlQuery createQuery() const;
bool beginTransaction(); bool beginTransaction();
bool commitTransaction(); bool commitTransaction();

@ -504,6 +504,8 @@ bool TQMYSQLDriver::open( const TQString& db,
optionFlags |= CLIENT_ODBC; optionFlags |= CLIENT_ODBC;
else if ( opt == "CLIENT_SSL" ) else if ( opt == "CLIENT_SSL" )
optionFlags |= CLIENT_SSL; optionFlags |= CLIENT_SSL;
else if ( opt == "MYSQL_OPT_RECONNECT" )
optionFlags |= MYSQL_OPT_RECONNECT;
else else
tqWarning( "TQMYSQLDriver::open: Unknown connect option '%s'", (*it).latin1() ); tqWarning( "TQMYSQLDriver::open: Unknown connect option '%s'", (*it).latin1() );
} }
@ -544,6 +546,21 @@ void TQMYSQLDriver::close()
} }
} }
bool TQMYSQLDriver::ping()
{
if ( !isOpen() ) {
return FALSE;
}
if (mysql_ping( d->mysql )) {
return TRUE;
}
else {
setLastError( qMakeError("Unable to execute ping", TQSqlError::Statement, d ) );
return FALSE;
}
}
TQSqlQuery TQMYSQLDriver::createQuery() const TQSqlQuery TQMYSQLDriver::createQuery() const
{ {
return TQSqlQuery( new TQMYSQLResult( this ) ); return TQSqlQuery( new TQMYSQLResult( this ) );

@ -100,6 +100,7 @@ public:
const TQString & host = TQString::null, const TQString & host = TQString::null,
int port = -1 ); int port = -1 );
void close(); void close();
bool ping();
TQSqlQuery createQuery() const; TQSqlQuery createQuery() const;
TQStringList tables( const TQString& user ) const; TQStringList tables( const TQString& user ) const;
TQSqlIndex primaryIndex( const TQString& tablename ) const; TQSqlIndex primaryIndex( const TQString& tablename ) const;

@ -1490,6 +1490,13 @@ void TQODBCDriver::close()
setOpenError( FALSE ); setOpenError( FALSE );
} }
bool TQODBCDriver::ping()
{
// FIXME
// Implement ping if supported
return TRUE;
}
void TQODBCDriver::cleanup() void TQODBCDriver::cleanup()
{ {
SQLRETURN r; SQLRETURN r;

@ -128,6 +128,7 @@ public:
const TQString & host = TQString::null, const TQString & host = TQString::null,
int port = -1 ); int port = -1 );
void close(); void close();
bool ping();
TQSqlQuery createQuery() const; TQSqlQuery createQuery() const;
TQStringList tables( const TQString& user ) const; TQStringList tables( const TQString& user ) const;
TQSqlRecord record( const TQString& tablename ) const; TQSqlRecord record( const TQString& tablename ) const;

@ -679,6 +679,29 @@ void TQPSQLDriver::close()
} }
} }
bool TQPSQLDriver::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", TQSqlError::Statement, d ) );
return FALSE;
}
}
return TRUE;
}
TQSqlQuery TQPSQLDriver::createQuery() const TQSqlQuery TQPSQLDriver::createQuery() const
{ {
return TQSqlQuery( new TQPSQLResult( this, d ) ); return TQSqlQuery( new TQPSQLResult( this, d ) );

@ -98,6 +98,7 @@ public:
const TQString & host = TQString::null, const TQString & host = TQString::null,
int port = -1 ); int port = -1 );
void close(); void close();
bool ping();
TQSqlQuery createQuery() const; TQSqlQuery createQuery() const;
TQStringList tables( const TQString& user ) const; TQStringList tables( const TQString& user ) const;
TQSqlIndex primaryIndex( const TQString& tablename ) const; TQSqlIndex primaryIndex( const TQString& tablename ) const;

@ -352,6 +352,17 @@ void TQSQLiteDriver::close()
} }
} }
bool TQSQLiteDriver::ping()
{
if ( !isOpen() ) {
return FALSE;
}
// FIXME
// Implement ping if available
return TRUE;
}
TQSqlQuery TQSQLiteDriver::createQuery() const TQSqlQuery TQSQLiteDriver::createQuery() const
{ {
return TQSqlQuery(new TQSQLiteResult(this)); return TQSqlQuery(new TQSQLiteResult(this));

@ -72,6 +72,7 @@ public:
const TQString & host, const TQString & host,
int port ) { return open (db, user, password, host, port, TQString()); } int port ) { return open (db, user, password, host, port, TQString()); }
void close(); void close();
bool ping();
TQSqlQuery createQuery() const; TQSqlQuery createQuery() const;
bool beginTransaction(); bool beginTransaction();
bool commitTransaction(); bool commitTransaction();

@ -336,6 +336,17 @@ void TQSQLite3Driver::close()
} }
} }
bool TQSQLite3Driver::ping()
{
if ( !isOpen() ) {
return FALSE;
}
// FIXME
// Implement ping if available
return TRUE;
}
TQSqlQuery TQSQLite3Driver::createQuery() const TQSqlQuery TQSQLite3Driver::createQuery() const
{ {
return TQSqlQuery(new TQSQLite3Result(this)); return TQSqlQuery(new TQSQLite3Result(this));

@ -72,6 +72,7 @@ public:
const TQString & host, const TQString & host,
int port ) { return open (db, user, password, host, port, TQString()); } int port ) { return open (db, user, password, host, port, TQString()); }
void close(); void close();
bool ping();
TQSqlQuery createQuery() const; TQSqlQuery createQuery() const;
bool beginTransaction(); bool beginTransaction();
bool commitTransaction(); bool commitTransaction();

@ -95,6 +95,7 @@ public:
bool open(); bool open();
bool open( const TQString& user, const TQString& password ); bool open( const TQString& user, const TQString& password );
void close(); void close();
bool ping();
bool isOpen() const; bool isOpen() const;
bool isOpenError() const; bool isOpenError() const;
TQStringList tables() const; TQStringList tables() const;

@ -98,6 +98,7 @@ public:
const TQString & host = TQString::null, const TQString & host = TQString::null,
int port = -1 ) = 0; int port = -1 ) = 0;
virtual void close() = 0; virtual void close() = 0;
virtual bool ping() = 0;
virtual TQSqlQuery createQuery() const = 0; virtual TQSqlQuery createQuery() const = 0;
// ### remove for 4.0 // ### remove for 4.0

@ -144,6 +144,7 @@ public:
return FALSE; return FALSE;
} }
void close() {} void close() {}
bool ping() { return TRUE; }
TQSqlQuery createQuery() const { return TQSqlQuery( new TQNullResult(this) ); } TQSqlQuery createQuery() const { return TQSqlQuery( new TQNullResult(this) ); }
}; };
@ -795,6 +796,15 @@ void TQSqlDatabase::close()
d->driver->close(); d->driver->close();
} }
/*!
Sends a ping to the database server.
*/
bool TQSqlDatabase::ping()
{
return d->driver->ping();
}
/*! /*!
Returns TRUE if the database connection is currently open; Returns TRUE if the database connection is currently open;
otherwise returns FALSE. otherwise returns FALSE.

Loading…
Cancel
Save