19 const
string& password)
24 fNumConnectedStatements(0),
26 fUrlValidated(kFALSE),
33 cout <<
"-I- FairDbConnection : Creating a DB connection" << endl;
36 cout <<
" -I- FairDbConnection: successfully opened connection to: "
37 << this->GetUrl() << endl;
38 fUrlValidated = kTRUE;
41 this->SetTableExists();
42 string productName(fServer->GetDBMS());
49 cout<<
"-E- FairDbConnection : Cannot determine DB type from name: "
51 <<
"\nWill assuming Oracle database " << endl;
55 if ( fUrlValidated ) {
56 if ( ! fServer->HasStatement() ) {
57 cout <<
"-I- FairDbConnection : This client does not support prepared statements." << endl;
58 fUrlValidated = kFALSE;
60 string serverInfo(fServer->ServerInfo());
62 cout <<
"-I- FairDbConnection: this MySQL server (" << serverInfo
63 <<
") does not support prepared statements." << endl;
64 fUrlValidated = kFALSE;
66 if ( fUrlValidated ) {
67 cout <<
"-I- FairDbConnection: this client, and MySQL server ("
69 <<
") does support prepared statements." << endl;
72 cout<<
"-I- FairDbConnection "<< endl;
73 cout<<
"This version of MySQL does not support prepared statements.\n"
75 <<
"Please upgrade to MySQL (client and server) version 4.1 or greater \n"
81 if ( ! fUrlValidated ) {
82 cout <<
"-E- FairDbConnection : Aborting due to above errors" << endl;
86 fDbName = fUrl.GetFile();
93 cout <<
"-I- FairDBConnection::~FairDbConnection() : Droping Connection"
102 if ( !this->
IsClosed() ) {
return kTRUE;}
105 for (Int_t attempt = 1; attempt <= maxAttempt; ++attempt) {
112 cout <<
"-E- Failing to open: " <<
113 fUrl.GetUrl() <<
" for user "
114 <<
fUser <<
" and password "
118 if ( attempt == 1 ) {
119 cout <<
"-I- FairDBConnection: Retrying ... " << endl;
121 gSystem->Sleep(attempt*1000);
123 fServer->EnableErrorOutput(
false);
125 cout <<
"-I- FairDbConnection Connection opened on attempt "
128 cout <<
"-I- Successfully opened connection to: "
129 <<
fUrl.GetUrl() << endl;
138 cout <<
" -E- FairDbConnection: Failed to open a connection to: "
148 if ( this->
IsClosed() ) {
return kTRUE; }
152 cout<<
"-I- FairDbConnection Unable to close connection: "
158 cout <<
"-I- FairDbConnection : closing connection: "
160 <<
"; even though it still has "
166 cout <<
"-I- FairDbConnection: closed connection: "
167 << this->
GetUrl() << endl;
182 TSQLStatement* stmt = 0;
183 if ( ! this->
Open() ) {
return stmt; }
184 stmt =
fServer->Statement(sql.c_str());
186 cout<<
"-E- FairDbConnection::CreatePreparedStatement "
187 <<
" no Statement created " << endl;
188 }
else { stmt->EnableErrorOutput(kFALSE); }
196 if ( ! this->
Open() ) {
return 0; }
215 if ( tableName ==
"" ) {
218 if (stmt->Process()) {
220 while (stmt->NextResultRow()) {
221 string tn(stmt->GetString(0));