49 |
fNquery = 0; |
fNquery = 0; |
50 |
}; |
}; |
51 |
|
|
52 |
Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){ |
Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){ |
53 |
// |
// |
54 |
// |
// |
55 |
// |
// |
59 |
// |
// |
60 |
// |
// |
61 |
// |
// |
62 |
// printf(" host is %s \n",fHost->Data()); |
// printf(" host is %s \n",fHost->Data()); |
63 |
// |
// |
64 |
stringstream myquery; |
stringstream myquery; |
65 |
myquery.str(""); |
myquery.str(""); |
66 |
myquery << "show databases;"; |
myquery << "show databases;"; |
67 |
dbc->Query(myquery.str().c_str()); |
if ( dbc ){ |
68 |
fNquery++; |
if ( dbc->IsConnected() ){ |
69 |
// |
dbc->Query(myquery.str().c_str()); |
70 |
if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
fNquery++; |
71 |
// is connected |
if ( !(dbc->GetErrorCode()) ){ |
72 |
return true; |
// printf("ok\n"); |
73 |
} else { |
// |
74 |
|
// if ( (dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006) ){ |
75 |
|
// if ( !(dbc->GetErrorCode()) ){ |
76 |
|
// is connected |
77 |
|
return true; |
78 |
|
// }; |
79 |
|
}; |
80 |
|
}; |
81 |
|
}; |
82 |
|
// printf("porca di quella \n"); |
83 |
|
if ( true ) { |
84 |
// |
// |
85 |
printf(" WARNING: Lost connection to DB! try to recover... \n"); |
printf(" WARNING: Lost connection to DB! try to recover... \n"); |
86 |
// |
// |
94 |
myquery << "show databases;"; |
myquery << "show databases;"; |
95 |
dbc->Query(myquery.str().c_str()); |
dbc->Query(myquery.str().c_str()); |
96 |
fNquery++; |
fNquery++; |
97 |
|
// printf(" e riporca di quella \n"); |
98 |
// |
// |
99 |
if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
100 |
|
if ( !(dbc->GetErrorCode()) ){ |
101 |
// |
// |
102 |
printf(" ...connection recovered, I can continue! \n"); |
printf(" ...connection recovered, I can continue! \n"); |
103 |
// |
// |
1820 |
TSQLRow *row; |
TSQLRow *row; |
1821 |
|
|
1822 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
1823 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1824 |
dbc->Query("SET time_zone = '+0:00'"); |
dbc->Query("SET time_zone = '+0:00'"); |
1825 |
|
|
1826 |
// Do the query |
// Do the query |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
|
1827 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1828 |
result = dbc->Query(myquery.Data()); |
result = dbc->Query(myquery.Data()); |
1829 |
if(! result->GetRowCount() ) { |
if(! result->GetRowCount() ) { |