| 38 |
fPsw = new TString(psw.Data()); |
fPsw = new TString(psw.Data()); |
| 39 |
fSet = true; |
fSet = true; |
| 40 |
fNquery = 0; |
fNquery = 0; |
| 41 |
|
mh = host.Data(); |
| 42 |
|
mu = user.Data(); |
| 43 |
|
mp = psw.Data(); |
| 44 |
}; |
}; |
| 45 |
|
|
| 46 |
|
|
| 50 |
fPsw = new TString(psw.Data()); |
fPsw = new TString(psw.Data()); |
| 51 |
fSet = true; |
fSet = true; |
| 52 |
fNquery = 0; |
fNquery = 0; |
| 53 |
|
mh = host.Data(); |
| 54 |
|
mu = user.Data(); |
| 55 |
|
mp = psw.Data(); |
| 56 |
}; |
}; |
| 57 |
|
|
| 58 |
Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){ |
Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){ |
| 59 |
// |
// |
| 60 |
// |
// |
| 61 |
// |
// |
| 65 |
// |
// |
| 66 |
// |
// |
| 67 |
// |
// |
| 68 |
// printf(" host is %s \n",fHost->Data()); |
// printf(" host is %s \n",fHost->Data()); |
| 69 |
// |
// |
| 70 |
stringstream myquery; |
stringstream myquery; |
| 71 |
myquery.str(""); |
myquery.str(""); |
| 72 |
myquery << "show databases;"; |
myquery << "show databases;"; |
| 73 |
dbc->Query(myquery.str().c_str()); |
if ( dbc ){ |
| 74 |
fNquery++; |
if ( dbc->IsConnected() ){ |
| 75 |
// |
dbc->Query(myquery.str().c_str()); |
| 76 |
if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
fNquery++; |
| 77 |
// is connected |
if ( !(dbc->GetErrorCode()) ){ |
| 78 |
return true; |
// printf("ok\n"); |
| 79 |
} else { |
// |
| 80 |
|
// if ( (dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006) ){ |
| 81 |
|
// if ( !(dbc->GetErrorCode()) ){ |
| 82 |
|
// is connected |
| 83 |
|
return true; |
| 84 |
|
// }; |
| 85 |
|
}; |
| 86 |
|
}; |
| 87 |
|
}; |
| 88 |
|
// printf("porca di quella \n"); |
| 89 |
|
if ( true ) { |
| 90 |
// |
// |
| 91 |
printf(" WARNING: Lost connection to DB! try to recover... \n"); |
printf(" WARNING: Lost connection to DB! try to recover... \n"); |
| 92 |
// |
// |
| 100 |
myquery << "show databases;"; |
myquery << "show databases;"; |
| 101 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
| 102 |
fNquery++; |
fNquery++; |
| 103 |
|
// printf(" e riporca di quella \n"); |
| 104 |
// |
// |
| 105 |
if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
| 106 |
|
if ( !(dbc->GetErrorCode()) ){ |
| 107 |
// |
// |
| 108 |
printf(" ...connection recovered, I can continue! \n"); |
printf(" ...connection recovered, I can continue! \n"); |
| 109 |
// |
// |
| 1826 |
TSQLRow *row; |
TSQLRow *row; |
| 1827 |
|
|
| 1828 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
| 1829 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
| 1830 |
dbc->Query("SET time_zone = '+0:00'"); |
dbc->Query("SET time_zone = '+0:00'"); |
| 1831 |
|
|
| 1832 |
// Do the query |
// Do the query |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
|
| 1833 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
| 1834 |
result = dbc->Query(myquery.Data()); |
result = dbc->Query(myquery.Data()); |
| 1835 |
if(! result->GetRowCount() ) { |
if(! result->GetRowCount() ) { |