Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSQLDatabase.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cSQLDatabase_H
7 #define _INC_cSQLDatabase_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cSQLBase.h"
13 #include "cSQLCmd.h"
15 #include "GrayCore/include/cAtom.h"
17 
18 namespace GrayLib
19 {
20  class GRAYLIB_LINK cSQLCmd;
26 
28  : public cSQLBase
29  , public cRefBase
30  {
35 
36  private:
37  cSQLConnectionString m_ConnectionString;
38  bool m_bIsConnected;
39  cSQLConfigDB m_ConfigDB;
40 
41  public:
43 
44  protected:
45  void ChangeCriticalWait(int iDelta);
46  HRESULT ReadConfigDB();
47  bool AllocISQLDatabase(cSQLDriver* pSQLDriver);
48  HRESULT OpenConnectInt(cExceptionHolder* pExceptionHolder, int iMaxRetries, TIMESYS_t nTimeStart);
49 
50  public:
51  cSQLDatabase();
52  virtual ~cSQLDatabase();
53 
54  ISQLDatabase* get_ISQLDatabase() const;
55 
56  bool isConnected() const
57  {
59  return m_bIsConnected;
60  }
61  bool IsExtReferenced(int nCheckVal = 1) const;
62  virtual cSQLDriver* get_SQLDriver() const
63  {
64  return m_pSQLDriver;
65  }
66  virtual cSQLBase* get_SQLParent() const;
67 
68  HRESULT OpenConnect(cStringF sConnectionString, cExceptionHolder* pExceptionHolder = nullptr, int iMaxRetries = 3);
69  HRESULT RetryOpenConnect(cExceptionHolder* pExceptionHolder = nullptr, int iMaxRetries = 100);
70  bool Close(bool bDestroyHandle);
71 
72  bool get_AutoCommit() const;
73  void put_AutoCommit(bool bAutoCommit); // makes all transactions COMMIT immediately
74 
75  const cSQLConfigDB& GetConfigDB();
76 
77  HRESULT ExecuteSQLCmd( cSQLCmd& oCmd, cExceptionHolder* pExceptionRet = nullptr);
78  HRESULT ExecuteSQLAndFetch(cSQLCmd& oCmd, cSQLStatement& rResultSet, cExceptionHolder* pExceptionRet = nullptr, bool bWaitIfBusy=false);
79  HRESULT ExecuteSQLOrInsert(cSQLCmdUpdate& oCmdUpdate, cExceptionHolder* pExceptionRet);
80 
81  HRESULT EndTransaction(bool bCommit);
82  };
83 
85 };
86 #endif // _INC_cSQLDatabase_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cSQLBase.h:78
Definition: cSQLCmd.h:288
Definition: cSQLCmd.h:114
Definition: cSQLCmd.h:36
Definition: cSQLConfig.h:103
Definition: cSQLBase.h:30
Definition: cSQLDatabase.h:30
cSQLDriver * m_pSQLDriver
My parent. Not set until after OpenConnect and m_bIsConnected.
Definition: cSQLDatabase.h:42
virtual cSQLDriver * get_SQLDriver() const
What driver ultimately owns this?
Definition: cSQLDatabase.h:62
bool isConnected() const
Definition: cSQLDatabase.h:56
Definition: cSQLMgr.h:25
Definition: cSQLStatement.h:33
Definition: cException.h:28
Definition: cRefPtr.h:22
Definition: ISQLDriver.h:44
Definition: cMesh.h:22
cRefPtr< cSQLDatabase > cSQLDatabasePtr
Definition: cSQLDatabase.h:84
DECLARE_INTERFACE(IScriptableSetter)
class __DECL_IMPORT cSQLDatabase
Definition: cSQLStatement.h:25
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27