中间件标准版5.1git,去除基础模块

DBCtrl.h 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*************************************************************************
  2. 【文件名】 DBCtrl.h
  3. 【功能模块和目的】 数据库模块导出类头文件
  4. 【开发者及日期】 郑石诺 2015/01/08
  5. 【版本】 V1.0.0
  6. 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
  7. 【更改记录】
  8. *************************************************************************/
  9. #pragma once
  10. #ifdef DBCTRL_EXPORTS
  11. #define DBCTRL_API __declspec(dllexport)
  12. #else
  13. #define DBCTRL_API __declspec(dllimport)
  14. #endif
  15. #define OTL_MAX_BUFF_SIZE 1024 // 字符串缓冲区最大长度
  16. #define OTL_MAX_TEXT_SIZE 4096 // TEXT缓冲区最大长度
  17. #define OTL_REG_KEY_SIZE 256 // 注册表键值最大长度
  18. // 数据库类型
  19. typedef enum tagDB_TYPE
  20. {
  21. DB_SQLServer = 0,
  22. DB_MySQL = 1,
  23. DB_Oracle = 2,
  24. DB_Error = 3
  25. } DB_TYPE;
  26. /*************************************************************************
  27. 【类名】 IOtlRecordset
  28. 【功能】 OTL连接控制记录集接口
  29. 【接口说明】
  30. 【开发者及日期】 郑石诺 2015/01/08
  31. 【版本】 V1.0.0
  32. 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
  33. 【更改记录】
  34. *************************************************************************/
  35. class DBCTRL_API IOtlRecordset
  36. {
  37. public:
  38. virtual ~IOtlRecordset(void) = 0 {}
  39. static void DestroyInstance(IOtlRecordset* pRecord);
  40. // 数据控制
  41. virtual BOOL IsEOF(void) = 0; // 是否已遍历到记录保结尾
  42. virtual BOOL MoveNextRow(void) = 0; // 移动记录集到下一行
  43. virtual BOOL GetValueInt(char *pColName, int &nValue) = 0; // 获取当前行指定字段值 整形
  44. virtual BOOL GetValueStr(char *pColName, char *pValue) = 0; // 获取当前行指定字段值 字符串
  45. virtual BOOL GetValueText(char *pColName, char *pValue) = 0; // 获取当前行指定字段值 较大文本值
  46. virtual BOOL GetValueFloat(char *pColName, float &Value) = 0; // 获取当前行指定字段值 浮点
  47. virtual int GetValueIntByIndex(int index) = 0; // 通过字段ID获取整型记录
  48. virtual int GetValueInt(CString FieldName) = 0; // 通过字段名称获取整型记录
  49. virtual CString GetValueStrByIndex(int index) = 0; // 通过字段ID获取字符串记录
  50. virtual CString GetValueStr(CString FieldName) = 0; // 通过字段名称获取字符串记录
  51. virtual BOOL GetValueFloatByIndex(int index, float &Value) = 0; // 通过字段ID获取浮点记录
  52. // 错误处理
  53. virtual LPCTSTR GetLastError(void) = 0;
  54. };
  55. /*************************************************************************
  56. 【类名】 IOtlStoredProc
  57. 【功能】 存储过程执行实体(仅供需返回值的存储过程或存储函数)
  58. 【接口说明】
  59. 【开发者及日期】 郑石诺 2015/01/08
  60. 【版本】 V1.0.0
  61. 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
  62. 【更改记录】
  63. *************************************************************************/
  64. class DBCTRL_API IOtlStoredProc
  65. {
  66. public:
  67. virtual ~IOtlStoredProc(void) = 0 {}
  68. static void DestroyInstance(IOtlStoredProc* a_pProc);
  69. // 添加存储过程输入参数(目前仅实现了两种重载,后续根据需要可自行添加)
  70. virtual BOOL Input(LPCTSTR a_StrParam) = 0;
  71. virtual BOOL Input(UINT a_UintParam) = 0;
  72. virtual BOOL Input(int a_IntParam) = 0;
  73. // 存储过程执行完毕输出参数(目前仅实现了两种重载,后续根据需要可自行添加)
  74. virtual BOOL Output(UINT& a_UintReturn) = 0;
  75. virtual BOOL Output(int& a_IntParam) = 0;
  76. virtual BOOL Output(LPTSTR a_StrParam) = 0;
  77. virtual BOOL Output(float a_FloatParam) = 0;
  78. // 错误处理
  79. virtual LPCTSTR GetLastError(void) = 0;
  80. };
  81. /*************************************************************************
  82. 【类名】 IOtlConnection
  83. 【功能】 OTL连接控制接口
  84. 【接口说明】
  85. 【开发者及日期】 郑石诺 2015/01/08
  86. 【版本】 V1.0.0
  87. 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
  88. 【更改记录】
  89. *************************************************************************/
  90. class DBCTRL_API IOtlConnection
  91. {
  92. public:
  93. virtual ~IOtlConnection(void) = 0 {}
  94. static IOtlConnection* getInstance(void);
  95. static void Initialize(void);
  96. // 数据库连接控制
  97. virtual BOOL Connect() = 0; // 连接数据库(注册表中默认配置的数据库)
  98. virtual BOOL Connect(LPCTSTR lpszConnString) = 0; // 连接指定数据库
  99. virtual BOOL ConnectTest(LPCTSTR lpszConnString, LPSTR lpErrInfo) = 0; // 连接测试
  100. virtual void Disconnect() = 0; // 断开连接
  101. virtual DB_TYPE GetDatabaseType() = 0; // 获取数据库类型
  102. // 数据操作
  103. virtual BOOL ExecCommand(LPCTSTR lpszSQL) = 0; // 直接命令执行
  104. virtual void DropTableCommand(LPCTSTR lpszSQL) = 0; // 删除表命令函数
  105. virtual BOOL InsertConstant(LPCTSTR lpszSQL) = 0; // 恒量插入(单数据)
  106. virtual BOOL GetSingleDataString(LPCTSTR lpszSQL, CHAR* lpValue) = 0; // 获取字符串单值
  107. virtual BOOL GetSingleDataText(LPCTSTR lpszSQL, CHAR* lpValue) = 0; // 获取Text串单值
  108. virtual BOOL GetSingleDataInt(LPCTSTR lpszSQL, LONG& nValue) = 0; // 获取整型单值
  109. virtual long GetSingleDataInt(LPCTSTR strSql) = 0; // 获取整型单值
  110. virtual CString GetSingleDataStr(LPCTSTR strSql) = 0; // 获取字符串单值
  111. virtual long GetSingleDataStr2Int(LPCTSTR strSql) = 0; // 获取字符串单值并转化成整型返回
  112. virtual IOtlRecordset* QueryRecords(LPCTSTR lpszSQL) = 0; // 查询记录集
  113. virtual IOtlStoredProc* CallStoredProc(const CString& a_DeclareWord) = 0; // 调用存储过程
  114. // 错误处理
  115. virtual LPCTSTR GetLastError() = 0;
  116. };