diff --git a/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx b/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx index 6658f01e7..b7bf1c76a 100644 --- a/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx +++ b/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx,v $ ------------------------------------------------------------------------------*/ @@ -57,6 +57,17 @@ using namespace LiveSupport::Scheduler; const std::string PostgresqlPlayLog::configElementNameStr = "postgresqlPlayLog"; +/*------------------------------------------------------------------------------ + * A statement to check if the database can be accessed. + *----------------------------------------------------------------------------*/ +const std::string PostgresqlPlayLog::check1Stmt = "SELECT 1"; + +/*------------------------------------------------------------------------------ + * A statement to check if the log table exists. + *----------------------------------------------------------------------------*/ +const std::string PostgresqlPlayLog::logCountStmt = + "SELECT COUNT(*) FROM playLog"; + /*------------------------------------------------------------------------------ * The SQL create statement, used for installation. *----------------------------------------------------------------------------*/ @@ -158,7 +169,7 @@ PostgresqlPlayLog :: isInstalled(void) throw (std::exception) // see if we can connect at all stmt.reset(conn->createStatement()); - stmt->execute("SELECT 1"); + stmt->execute(check1Stmt); res = stmt->getResultSet(); if (!res->next() || (res->getInt(1) != 1)) { throw std::runtime_error("Can't connect to database"); @@ -167,7 +178,7 @@ PostgresqlPlayLog :: isInstalled(void) throw (std::exception) // see if the schedule table exists try { stmt.reset(conn->createStatement()); - stmt->execute("SELECT COUNT(*) FROM playLog"); + stmt->execute(logCountStmt); res = stmt->getResultSet(); if (!res->next() || (res->getInt(1) < 0)) { cm->returnConnection(conn); diff --git a/livesupport/products/scheduler/src/PostgresqlPlayLog.h b/livesupport/products/scheduler/src/PostgresqlPlayLog.h index 5cb1a9069..c624585cf 100644 --- a/livesupport/products/scheduler/src/PostgresqlPlayLog.h +++ b/livesupport/products/scheduler/src/PostgresqlPlayLog.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.h,v $ ------------------------------------------------------------------------------*/ @@ -81,7 +81,7 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class PostgresqlPlayLog : public Configurable, public PlayLogInterface @@ -92,6 +92,16 @@ class PostgresqlPlayLog : public Configurable, */ static const std::string configElementNameStr; + /** + * A SQL statement to check if the database can be accessed. + */ + static const std::string check1Stmt; + + /** + * A SQL statement to check if the log table exists. + */ + static const std::string logCountStmt; + /** * The SQL create statement used in the installation step. */ diff --git a/livesupport/products/scheduler/src/PostgresqlSchedule.cxx b/livesupport/products/scheduler/src/PostgresqlSchedule.cxx index ab95fd004..9568b7385 100644 --- a/livesupport/products/scheduler/src/PostgresqlSchedule.cxx +++ b/livesupport/products/scheduler/src/PostgresqlSchedule.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.12 $ + Version : $Revision: 1.13 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.cxx,v $ ------------------------------------------------------------------------------*/ @@ -57,6 +57,17 @@ using namespace LiveSupport::Scheduler; const std::string PostgresqlSchedule::configElementNameStr = "postgresqlSchedule"; +/*------------------------------------------------------------------------------ + * A statement to check if the database can be accessed. + *----------------------------------------------------------------------------*/ +const std::string PostgresqlSchedule::check1Stmt = "SELECT 1"; + +/*------------------------------------------------------------------------------ + * A statement to check if the schedule table exists. + *----------------------------------------------------------------------------*/ +const std::string PostgresqlSchedule::scheduleCountStmt = + "SELECT COUNT(*) FROM schedule"; + /*------------------------------------------------------------------------------ * The SQL create statement, used for installation. *----------------------------------------------------------------------------*/ @@ -210,7 +221,7 @@ PostgresqlSchedule :: isInstalled(void) throw (std::exception) // see if we can connect at all stmt.reset(conn->createStatement()); - stmt->execute("SELECT 1"); + stmt->execute(check1Stmt); res = stmt->getResultSet(); if (!res->next() || (res->getInt(1) != 1)) { throw std::runtime_error("Can't connect to database"); @@ -219,7 +230,7 @@ PostgresqlSchedule :: isInstalled(void) throw (std::exception) // see if the schedule table exists try { stmt.reset(conn->createStatement()); - stmt->execute("SELECT COUNT(*) FROM schedule"); + stmt->execute(scheduleCountStmt); res = stmt->getResultSet(); if (!res->next() || (res->getInt(1) < 0)) { return false; diff --git a/livesupport/products/scheduler/src/PostgresqlSchedule.h b/livesupport/products/scheduler/src/PostgresqlSchedule.h index 0fb7004be..8a07e310e 100644 --- a/livesupport/products/scheduler/src/PostgresqlSchedule.h +++ b/livesupport/products/scheduler/src/PostgresqlSchedule.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $ ------------------------------------------------------------------------------*/ @@ -81,7 +81,7 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class PostgresqlSchedule : public Configurable, public ScheduleInterface @@ -92,6 +92,16 @@ class PostgresqlSchedule : public Configurable, */ static const std::string configElementNameStr; + /** + * A SQL statement to check if the database can be accessed. + */ + static const std::string check1Stmt; + + /** + * A SQL statement to check if the schedule table exists. + */ + static const std::string scheduleCountStmt; + /** * The SQL create statement used in the installation step. */