Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:22:02

0001 // $Id: MySQLConnectionPrivate.h,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $
0002 
0003 #ifndef RDBC_MySQLConnectionPrivate_h
0004 #define RDBC_MySQLConnectionPrivate_h
0005 
0006 //
0007 // Very private MySQL part of TSQLConnection
0008 //
0009 
0010 #include <mysql.h>
0011 
0012 /////////////////////////////////////////////////////////////////////
0013 class MySQLConnectionPrivate 
0014 {
0015 friend class TSQLConnection;
0016 
0017 private:
0018    static const Int_t fgCheckIfAlive;  //Seconds between queries for ping (MyODBC-2.50.36)
0019 
0020    static Int_t fgMaxAllowedPacket = 65536;
0021    static Int_t fgNetBufferLength = 16384;
0022    static Int_t fgMaxReconnects = 3;
0023    static Int_t fgInitialTimeout = 2.0;
0024 
0025 //static const TString gPING_COMMAND = "SELECT 1";
0026 
0027 
0028    MYSQL*   fMYSQL; //
0029    Bool_t   fIsConnected; //
0030    Bool_t   fLocked;   //
0031 
0032    Bool_t   fReadOnly;  //
0033    TSQLUrl  fURL;       //
0034    time_t   fLastQueryTime; //
0035    Int_t    fLoginTimeout; //
0036 
0037    MySQLConnectionPrivate() { mysql_init(fMYSQL); }
0038 
0039 public:
0040    Bool_t CheckIfServerIsAlive();
0041    
0042 };
0043 
0044 
0045 const Int_t MySQLConnectionPrivate::fgCheckIfAlive = 3600;
0046 
0047 //___________________________________________________________________
0048 Bool_t MySQLConnectionPrivate::CheckIfServerIsAlive()
0049 {
0050    //
0051    time_t seconds = (time_t) time((time_t*) 0);
0052    Bool_t result  = kFALSE;
0053 
0054    if ((ULong_t) (seconds - fLastQueryTime) >= fgCheckIfAlive) {
0055       result = (mysql_ping(&dbc->mysql) && 
0056                mysql_errno(&dbc->mysql) == CR_SERVER_GONE_ERROR);
0057    }
0058   
0059    fLastQueryTime = seconds;
0060    return result;
0061 }
0062 
0063 
0064 #endif // RDBC_MySQLConnectionPrivate_h