溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

嵌入式MYSQL服務(wù)器的實現(xiàn)方法

發(fā)布時間:2021-09-15 13:57:08 來源:億速云 閱讀:154 作者:chen 欄目:數(shù)據(jù)庫

這篇文章主要介紹“嵌入式MYSQL服務(wù)器的實現(xiàn)方法”,在日常操作中,相信很多人在嵌入式MYSQL服務(wù)器的實現(xiàn)方法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”嵌入式MYSQL服務(wù)器的實現(xiàn)方法”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

 
//嵌入式MYSQL服務(wù)器

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; //是系統(tǒng)重新打開連接
 
    int     m_nStatus; // 0 :SQL 空閑狀態(tài) 1 :有SQL語句等待執(zhí)行 2:有結(jié)果數(shù)據(jù)待取出 
    int     m_nCount; //結(jié)果集記錄數(shù)量
    int     m_nCode; //執(zhí)行返回碼
    int     m_nSQLSize; //默認是16K
    string  m_sErr; //錯誤消息
    char    *m_pSQL; //SQL語句
    string  m_sSrc; //調(diào)用源
    bool    m_bError; //語句執(zhí)行是否出錯
    int     m_nDBType;  //驅(qū)動類型
    void    *m_pUniDBRecv; //保留
    bool    m_bTran; //事務(wù)標志
    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_)

到此,關(guān)于“嵌入式MYSQL服務(wù)器的實現(xiàn)方法”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI