modified source to contain constant strings separately, not in the code
This commit is contained in:
parent
66bd876f08
commit
a574e393c7
4 changed files with 52 additions and 10 deletions
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
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 =
|
const std::string PostgresqlPlayLog::configElementNameStr =
|
||||||
"postgresqlPlayLog";
|
"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.
|
* The SQL create statement, used for installation.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -158,7 +169,7 @@ PostgresqlPlayLog :: isInstalled(void) throw (std::exception)
|
||||||
|
|
||||||
// see if we can connect at all
|
// see if we can connect at all
|
||||||
stmt.reset(conn->createStatement());
|
stmt.reset(conn->createStatement());
|
||||||
stmt->execute("SELECT 1");
|
stmt->execute(check1Stmt);
|
||||||
res = stmt->getResultSet();
|
res = stmt->getResultSet();
|
||||||
if (!res->next() || (res->getInt(1) != 1)) {
|
if (!res->next() || (res->getInt(1) != 1)) {
|
||||||
throw std::runtime_error("Can't connect to database");
|
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
|
// see if the schedule table exists
|
||||||
try {
|
try {
|
||||||
stmt.reset(conn->createStatement());
|
stmt.reset(conn->createStatement());
|
||||||
stmt->execute("SELECT COUNT(*) FROM playLog");
|
stmt->execute(logCountStmt);
|
||||||
res = stmt->getResultSet();
|
res = stmt->getResultSet();
|
||||||
if (!res->next() || (res->getInt(1) < 0)) {
|
if (!res->next() || (res->getInt(1) < 0)) {
|
||||||
cm->returnConnection(conn);
|
cm->returnConnection(conn);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -81,7 +81,7 @@ using namespace LiveSupport::Core;
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
class PostgresqlPlayLog : public Configurable,
|
class PostgresqlPlayLog : public Configurable,
|
||||||
public PlayLogInterface
|
public PlayLogInterface
|
||||||
|
@ -92,6 +92,16 @@ class PostgresqlPlayLog : public Configurable,
|
||||||
*/
|
*/
|
||||||
static const std::string configElementNameStr;
|
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.
|
* The SQL create statement used in the installation step.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
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 =
|
const std::string PostgresqlSchedule::configElementNameStr =
|
||||||
"postgresqlSchedule";
|
"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.
|
* The SQL create statement, used for installation.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -210,7 +221,7 @@ PostgresqlSchedule :: isInstalled(void) throw (std::exception)
|
||||||
|
|
||||||
// see if we can connect at all
|
// see if we can connect at all
|
||||||
stmt.reset(conn->createStatement());
|
stmt.reset(conn->createStatement());
|
||||||
stmt->execute("SELECT 1");
|
stmt->execute(check1Stmt);
|
||||||
res = stmt->getResultSet();
|
res = stmt->getResultSet();
|
||||||
if (!res->next() || (res->getInt(1) != 1)) {
|
if (!res->next() || (res->getInt(1) != 1)) {
|
||||||
throw std::runtime_error("Can't connect to database");
|
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
|
// see if the schedule table exists
|
||||||
try {
|
try {
|
||||||
stmt.reset(conn->createStatement());
|
stmt.reset(conn->createStatement());
|
||||||
stmt->execute("SELECT COUNT(*) FROM schedule");
|
stmt->execute(scheduleCountStmt);
|
||||||
res = stmt->getResultSet();
|
res = stmt->getResultSet();
|
||||||
if (!res->next() || (res->getInt(1) < 0)) {
|
if (!res->next() || (res->getInt(1) < 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlSchedule.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -81,7 +81,7 @@ using namespace LiveSupport::Core;
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.8 $
|
* @version $Revision: 1.9 $
|
||||||
*/
|
*/
|
||||||
class PostgresqlSchedule : public Configurable,
|
class PostgresqlSchedule : public Configurable,
|
||||||
public ScheduleInterface
|
public ScheduleInterface
|
||||||
|
@ -92,6 +92,16 @@ class PostgresqlSchedule : public Configurable,
|
||||||
*/
|
*/
|
||||||
static const std::string configElementNameStr;
|
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.
|
* The SQL create statement used in the installation step.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue