Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MySQLConnectionPrivate.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MySQLConnectionPrivate.h
1 // $Id: MySQLConnectionPrivate.h,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
2 
3 #ifndef RDBC_MySQLConnectionPrivate_h
4 #define RDBC_MySQLConnectionPrivate_h
5 
6 //
7 // Very private MySQL part of TSQLConnection
8 //
9 
10 #include <mysql.h>
11 
14 {
15 friend class TSQLConnection;
16 
17 private:
18  static const Int_t fgCheckIfAlive; //Seconds between queries for ping (MyODBC-2.50.36)
19 
20  static Int_t fgMaxAllowedPacket = 65536;
21  static Int_t fgNetBufferLength = 16384;
22  static Int_t fgMaxReconnects = 3;
23  static Int_t fgInitialTimeout = 2.0;
24 
25 //static const TString gPING_COMMAND = "SELECT 1";
26 
27 
28  MYSQL* fMYSQL; //
29  Bool_t fIsConnected; //
30  Bool_t fLocked; //
31 
32  Bool_t fReadOnly; //
34  time_t fLastQueryTime; //
35  Int_t fLoginTimeout; //
36 
37  MySQLConnectionPrivate() { mysql_init(fMYSQL); }
38 
39 public:
40  Bool_t CheckIfServerIsAlive();
41 
42 };
43 
44 
46 
47 //___________________________________________________________________
49 {
50  //
51  time_t seconds = (time_t) time((time_t*) 0);
52  Bool_t result = kFALSE;
53 
54  if ((ULong_t) (seconds - fLastQueryTime) >= fgCheckIfAlive) {
55  result = (mysql_ping(&dbc->mysql) &&
56  mysql_errno(&dbc->mysql) == CR_SERVER_GONE_ERROR);
57  }
58 
59  fLastQueryTime = seconds;
60  return result;
61 }
62 
63 
64 #endif // RDBC_MySQLConnectionPrivate_h