modified source to contain constant strings separately, not in the code

This commit is contained in:
maroy 2005-04-08 12:07:58 +00:00
parent 66bd876f08
commit a574e393c7
4 changed files with 52 additions and 10 deletions

View file

@ -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);

View file

@ -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;
* </code></pre>
*
* @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.
*/

View file

@ -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;

View file

@ -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;
* </code></pre>
*
* @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.
*/