TDbiConnection.cxx File Reference

#include <cctype>
#include <cstdlib>
#include <list>
#include <sstream>
#include <string>
#include "TList.h"
#include "TString.h"
#include "TSystem.h"
#include "TDbi.hxx"
#include "TDbiAsciiDbImporter.hxx"
#include "TDbiConnection.hxx"
#include "TDbiExceptionLog.hxx"
#include "TDbiServices.hxx"
#include <TSK_DBI_Log.hxx>
#include <MsgFormat.h>
Include dependency graph for TDbiConnection.cxx:

Go to the source code of this file.

Functions

 ClassImp (TDbiConnection) TDbiConnection

Function Documentation

ClassImp ( TDbiConnection   ) 

Definition at line 27 of file TDbiConnection.cxx.

References SK_DBI_Info, SK_DBI_Severe, and SK_DBI_Trace.

00037                 : ctors, dtor, operators then in alphabetical order.
00038 
00039 //.....................................................................
00040 //      Throws EBadConnection() if can not make connection
00041 TDbiConnection::TDbiConnection(const std::string& url      /* = "" */,
00042                              const std::string& user     /* = "" */,
00043                              const std::string& password /* = "" */,
00044                              int maxConnects) :
00045 
00046 fUrl(url.c_str()),
00047 fUser(user),
00048 fPassword(password),
00049 fUrlValidated(false),
00050 fNumConnectedStatements(0),
00051 fIsTemporary(true),
00052 fServer(0)
00053 {
00054 //
00055 //
00056 //  Purpose:  Default constructor
00057 
00058   fMaxConnectionAttempts = maxConnects;
00059 
00060   SK_DBI_Trace( "Creating TDbiConnection" << "  ");
00061 
00062   if ( this->Open() ) {
00063     SK_DBI_Info(  "Successfully opened connection to: " << this->GetUrl() << "  ");
00064     fUrlValidated =  true;
00065 
00066     // Initialise the list existing supported tables.
00067     this->SetTableExists();
00068 
00069     //  If URL looks O.K., check that both client and server support prepared statements.
00070     if ( fUrlValidated ) {
00071 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,9)
00072       if ( ! fServer->HasStatement() ) {
00073 #else
00074       if ( ! fServer->IsSupportStatement() ) {
00075 #endif
00076         SK_DBI_Severe( "  This client does not support prepared statements." << "  ");
00077         fUrlValidated = false;
00078         #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,9)
00079       }
00080 #else
00081       }
00082 #endif
00083       
00084       std::string serverInfo(fServer->ServerInfo());
00085       if ( serverInfo < "4.1" ) {
00086         SK_DBI_Severe( "This MySQL server (" << serverInfo
00087                              << ") does NOT support prepared statements." << "  ");
00088         fUrlValidated = false;
00089       }
00090       if ( fUrlValidated ) {
00091         SK_DBI_Info( "This client, and MySQL server (" << serverInfo
00092                              << ") supports prepared statements." << "  ");
00093       }
00094       else {
00095 
00096         SK_DBI_Severe( "\n"
00097            << "This version of MySQL does not support prepared statements.\n"
00098            << "\n"
00099            << "Please upgrade to MySQL (client and server) version 4.1 or greater \n"
00100            << "\n"
00101            << "  ");
00102       }
00103 
00104     }
00105   }
00106     if ( ! fUrlValidated ) {
00107       SK_DBI_Severe( "FATAL: " << "Aborting due to above errors" << "  ");
00108       throw EBadConnection();
00109     }
00110    fDbName = fUrl.GetFile();
00111   
00112 
00113 }


Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1