rm_DB Class Reference
[Resource Manager Database Library]

#include <rmdb.h>

List of all members.


Detailed Description

Definition at line 770 of file rmdb.h.


Public Member Functions

void Connect ()
void Disconnect ()

Private Member Functions

bool Init ()
bool Drop ()
void DefineExtFunctions ()
void ExistExtFunctions ()
void Check ()
 rm_DB ()
 ~rm_DB ()

Private Attributes

bool connected
 log_CLASSID_m

Friends

class rm_Operator

Constructor & Destructor Documentation

rm_DB::rm_DB (  )  [private]

Definition at line 296 of file librmdb.exx.

References log_FUNC_m.

00296               {
00297 
00298     log_FUNC_m(rm_DB);
00299 } //rm_DB::rm_DB ()

rm_DB::~rm_DB (  )  [private]

Definition at line 303 of file librmdb.exx.

References log_FUNC_m.

00303                {
00304     log_FUNC_m(~rm_DB);
00305 } //rm_DB::~rm_DB ()


Member Function Documentation

void rm_DB::Connect (  ) 

Definition at line 248 of file librmdb.exx.

References Check(), dbg_LOW, errorDesc(), evt_ERROR, g_dbName(), log_DBG_m, log_FUNC_m, log_WriteEvent(), and SQL_NOERROR.

Referenced by rm_DBThread::Resume(), and rm_Operator::rm_Operator().

00248                     {
00249     log_FUNC_m(Connect);
00250 
00251     log_DBG_m(dbg_LOW, "g_dbName:" << g_dbName);
00252 
00253     EXEC SQL
00254         CONNECT DB;/* USER 'sysdba' PASSWORD 'masterkey';*/
00255 
00256     if (SQLCODE != SQL_NOERROR) {
00257         string sqlErrDesc = errorDesc(SQLCODE,"Can not Connect DB");
00258         log_WriteEvent(evt_ERROR, "Database can't be accessed. Is DB Server running?");
00259         throw ivd_DBException( SQLCODE ,sqlErrDesc, true);
00260 
00261         //throw ivd_Error( ie_RMDB_CONNECTPROBLEM ,"Can not connect to DB", true);
00262     };
00263     log_DBG_m(dbg_LOW, "CONNECTED");
00264     Check();
00265 
00266 
00267 }//rm_DB::Connect()

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_DB::Disconnect (  ) 

Definition at line 271 of file librmdb.exx.

References connected, dbg_LOW, errorDesc(), ie_RMDB_CONNECTPROBLEM, ivd_Error, log_DBG_m, log_FUNC_m, and SQL_NOERROR.

Referenced by rm_DBThread::Suspend(), and rm_Operator::~rm_Operator().

00271                        {
00272     log_FUNC_m(Disconnect);
00273 
00274    if (DB) {           /* Is the Database. connected?*/
00275 
00276        EXEC SQL
00277             DISCONNECT DB;
00278 
00279        if (SQLCODE != SQL_NOERROR) {
00280 
00281            string sqlErrDesc = errorDesc(SQLCODE,"Can not disconnect DB");
00282            throw ivd_DBException( SQLCODE ,sqlErrDesc, true);
00283 
00284            //throw ivd_Error( ie_RMDB_CONNECTPROBLEM ,"Can not disconnect DB", true);
00285        };
00286        connected = false;
00287        log_DBG_m(dbg_LOW, "DISCONNECT");
00288    }
00289    else {
00290        throw ivd_Error( ie_RMDB_CONNECTPROBLEM ,"Database NOT Connected. Cannot disconnect", true);
00291    }
00292 }//rm_DB::Disconnect()

Here is the call graph for this function:

Here is the caller graph for this function:

bool rm_DB::Init (  )  [private]

bool rm_DB::Drop (  )  [private]

void rm_DB::DefineExtFunctions (  )  [private]

Definition at line 399 of file librmdb.exx.

References dbg_NORM, errorDesc(), ExistExtFunctions(), log_DBG_m, log_FUNC_m, and SQL_CHECK_M.

00399                                {
00400     log_FUNC_m(DefineExtFunctions);
00401 
00402     try {
00403         ExistExtFunctions();
00404         log_DBG_m(dbg_NORM,"External function exists");
00405     } catch (ivd_Error) {
00406         EXEC SQL DECLARE EXTERNAL FUNCTION bin_and
00407                     INTEGER, INTEGER
00408                     RETURNS INTEGER BY VALUE
00409                     ENTRY_POINT 'IB_UDF_bin_and' MODULE_NAME 'ib_udf';
00410 
00411         string sqlErrDesc = errorDesc(SQLCODE, "define external function bin_and");
00412         SQL_CHECK_M( sqlErrDesc );
00413     };
00414 } //rm_DB::DefineExtFunctions

Here is the call graph for this function:

void rm_DB::ExistExtFunctions (  )  [private]

Definition at line 384 of file librmdb.exx.

References dbg_LOW, ie_RMDB_ERROR, ivd_Error, log_DBG_m, log_FUNC_m, and SQL_NOERROR.

Referenced by DefineExtFunctions().

00384                               {
00385 
00386     log_FUNC_m(ExistExtFunctions);
00387     EXEC SQL SELECT RDB$FUNCTION_NAME FROM RDB$FUNCTIONS WHERE RDB$FUNCTION_NAME = 'BIN_AND';
00388 
00389     if (SQLCODE != SQL_NOERROR) {
00390         throw ivd_Error(ie_RMDB_ERROR, "Missing External Function BIN_AND:" + SQLCODE);
00391     }
00392     else {
00393         log_DBG_m(dbg_LOW, "Found External Function BIN_AND");
00394     };
00395 } //rm_DB::ExistExtFunctions()

Here is the caller graph for this function:

void rm_DB::Check (  )  [private]

Definition at line 339 of file librmdb.exx.

References dbg_NORM, log_DBG_m, log_FUNC_m, and TableExists().

Referenced by Connect().

00339                   {
00340     log_FUNC_m(Check);
00341 
00342     //ExistExtFunctions();
00343     TableExists("LIBRARY");
00344     TableExists("DRIVE");
00345     TableExists("DRIVEHOST");
00346     TableExists("DISKSUBSYS");
00347     TableExists("MEDIAPOOL");
00348     TableExists("SLOT");
00349     TableExists("MEDIA");
00350     TableExists("MEDIAVOL");
00351     TableExists("PARTITION");
00352     TableExists("JOBID");
00353 
00354     log_DBG_m(dbg_NORM,"Check Tables success");
00355 /* user check NYI
00356     Int32_t userCount = 0;
00357     char userName[100];
00358     strcpy( userName, g_cmn.si.m_userName.c_str());
00359 
00360     unsigned int i = 0;
00361     while ( userName[i] != '\0' ){
00362         userName[i] = toupper(userName[i]);
00363         i++;
00364     }
00365 
00366     EXEC SQL
00367         SELECT COUNT (*)
00368         INTO :userCount
00369         FROM RDB$USER_PRIVILEGES
00370         WHERE RDB$USER = :userName;
00371 
00372     if ( userCount == 0 ) {
00373         ostringstream str;
00374         str << "No grant permission for user " << userName;
00375         log_DBG_m(dbg_LOW, str.str() << " count:" << userCount);
00376         throw ivd_Error(ie_RMDB_ERROR, str.str());
00377     }
00378 */
00379 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class rm_Operator [friend]

Definition at line 771 of file rmdb.h.


Member Data Documentation

bool rm_DB::connected [private]

Definition at line 778 of file rmdb.h.

Referenced by Disconnect().

Definition at line 832 of file rmdb.h.


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 19:46:08 2012 for OPENARCHIVE by  doxygen 1.5.6