/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 00002 #ifndef DBICONNECTION 00003 #define DBICONNECTION 00004 00005 00009 00031 #include <string> 00032 00033 #ifndef ROOT_Rtypes 00034 #if !defined(__CINT__) || defined(__MAKECINT__) 00035 #include "Rtypes.h" 00036 #endif 00037 #endif 00038 #include "TSQLServer.h" 00039 #include "TSQLStatement.h" 00040 #include "TUrl.h" 00041 00042 #include "DatabaseInterface/Dbi.h" 00043 #include "DatabaseInterface/DbiExceptionLog.h" 00044 #include "DatabaseInterface/DbiLog.h" 00045 00046 class DbiConnection 00047 { 00048 00049 public: 00050 00051 // Constructors and destructors. 00052 DbiConnection(const std::string& url = "", 00053 const std::string& user = "", 00054 const std::string& password = ""); 00055 virtual ~DbiConnection(); 00056 00057 // State testing member functions 00058 00059 // Standard getters. 00060 00061 const std::string& GetDbName() const { return fDbName; } 00062 Dbi::DbTypes GetDbType() const { return fDbType; } 00063 const std::string& GetPassword() const { return fPassword; } 00064 const std::string& GetUrl() const; 00065 const std::string& GetUser() const { return fUser; } 00066 Bool_t IsClosed() const { return ! fServer; } 00067 Bool_t IsTemporary() const { return fIsTemporary; } 00068 Int_t GetNumConnectedStatements() const { return fNumConnectedStatements ; } 00069 00070 // Exception log handling 00071 00072 const DbiExceptionLog& GetExceptionLog() const { return fExceptionLog; } 00073 void ClearExceptionLog() { fExceptionLog.Clear(); } 00074 00076 Bool_t PrintExceptionLog(Logging::Level level = 3) const; 00077 void RecordException(); 00078 00079 // State changing member functions 00080 00081 // Idle connnection management 00082 00084 void ConnectStatement() { ++fNumConnectedStatements; } 00086 void DisConnectStatement() { 00087 --fNumConnectedStatements; 00088 if ( ! fNumConnectedStatements ) this->CloseIdleConnection(); } 00090 void SetPermanent() { fIsTemporary = kFALSE; } 00091 00095 void SetLocking(Bool_t locking = kTRUE) { fIsLocking = locking; } 00096 Bool_t IsLocking() { return fIsLocking ; } 00097 00098 Bool_t Close(Bool_t force = false); 00099 Bool_t Open(); 00100 00103 TSQLServer* GetServer(); 00104 00107 TSQLStatement* CreatePreparedStatement(const std::string& sql); 00108 00109 private: 00110 00111 void CloseIdleConnection(); 00112 00113 00114 // Data members 00115 00117 std::string fDbName; 00118 00120 TUrl fUrl; 00121 00123 std::string fUser; 00124 00126 std::string fPassword; 00127 00129 Bool_t fUrlValidated; 00130 00132 Int_t fNumConnectedStatements; 00133 00135 Bool_t fIsTemporary; 00136 00138 Bool_t fIsLocking; 00139 00141 TSQLServer* fServer; 00142 00145 DbiExceptionLog fExceptionLog; 00146 00148 Dbi::DbTypes fDbType; 00149 00150 // Removed: ClassDef(DbiConnection,0) // Managed TSQLServer 00151 00152 }; 00153 00154 00155 #endif // DBICONNECTION 00156