这篇文章主要介绍“嵌入式MYSQL服务器的实现方法”,在日常操作中,相信很多人在嵌入式MYSQL服务器的实现方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”嵌入式MYSQL服务器的实现方法”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
//嵌入式MYSQL服务器
class CEmbeddedMySQL
{
public:
CEmbeddedMySQL();
virtual ~CEmbeddedMySQL();
static bool StartupEmbeddedServer();
static void ShutdownEmbeddedServer();
bool Open( const string &svr, const string &usr, const string &pwd, const string &db);
void Close();
bool ResetDB();
void Set( const string &sField, const string &sValue );
void Set( const string &sField, double dValue );
void Set( const string &sField, long nValue );
void Set( const string &sField, int nValue );
void Set( const string &sField, BYTE *pBuf, int nLen );
void SetNull( const string &sField );
void registerOutParameter( const string &sField, char cType );
// void SetRecord( const string &sField, const string &sTableName, const string &sTypeName, CStdRecord &Record );
void Cmd(const char *cmd,...);
bool More();
long Exec();
// bool SelectInto(CStdRecord *pRecord,bool bCreateHead=true);
double GetDouble(int id);
double GetDouble(const string &name);
long GetLong(int id);
long GetLong(const string &name);
string Get(int id);
string Get(const string &name);
string GetLastErrMsg();
char* GetSql();
bool MoreForUpdate();
bool SetBuffer( int nFieldIndex, BYTE *pBuf, long nSize );
bool SetBuffer( const string &sField, BYTE *pBuf, long nSize );
bool GetBuffer( const string &sField, BYTE *pBuf, long &nSize );
bool GetBuffer( int nFieldIndex, BYTE *pBuf, long &nSize );
long GetDataSize( const string &sField );
long GetDataSize( int nFieldIndex );
long GetActualSize( const string &sField );
long GetActualSize( int nFieldIndex );
void ClearSql();
long GetColIndex( const string &sField );
string GetColName( int nFiledIndex );
string GetColType( int index );
int GetNumCols();
string GetHeadScript();
int row_getsize();
bool row_gethead( string &sHead );
bool row_more( char *pData, int &nSize );
void SetAutoCommit( bool autoCommit );
void RollBack();
void Commit();
bool IsDead();
bool SetParam( int nType, const string &sVal );
protected:
void WriteSQLErrLog();
// 获取过程返回值
string GetStorageProReturnValue(const string &name);
void CopyRowData(char * pData,MYSQL_ROW row); // added by cailei
CStdString GetCurTime(time_t nTime=0);
long GetCurDate(time_t nTime=0);
MYSQL *m_hMySQL;
MYSQL_RES *m_pRes;
MYSQL_ROW m_Row;
MYSQL_FIELD *m_pFields;
long m_nRowSize;
bool m_bRegParam; // 是否注册了过程返回变量
protected:
string m_sSvr;
string m_sUser;
string m_sPwd;
string m_sDB;
string m_sUserMode;
bool m_bReopen; //是系统重新打开连接
int m_nStatus; // 0 :SQL 空闲状态 1 :有SQL语句等待执行 2:有结果数据待取出
int m_nCount; //结果集记录数量
int m_nCode; //执行返回码
int m_nSQLSize; //默认是16K
string m_sErr; //错误消息
char *m_pSQL; //SQL语句
string m_sSrc; //调用源
bool m_bError; //语句执行是否出错
int m_nDBType; //驱动类型
void *m_pUniDBRecv; //保留
bool m_bTran; //事务标志
void *m_pReq; www.2cto.com
byte *m_pReqBuf;
int m_nReqSize;
bool m_bDebug;
};
#endif // !defined(AFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_)
到此,关于“嵌入式MYSQL服务器的实现方法”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!