Embedded MYSQL server implementation // EmbeddedMySQL. h: interface for the CEmbeddedMySQL class. //////////////////////////////////////// /// // if! Defined (LOGIN _) # define Login _ www.2cto.com # if _ MSC_VER> 1000 # pragma once # endif // _ MSC_VER> 1000 # include <mysql. h> # include <string> # include "StdString. h "using namespace std; // embedded MYSQL server 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 (); www.2cto.com 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); www.2cto.com 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 ();
// Obtain the returned value 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); www.2cto.com MYSQL * m_hMySQL; MYSQL_RES * m_pRes; MYSQL_ROW m_Row; MYSQL_FIELD * m_pFields; long m_nRowSize; bool m_bRegParam; // whether the protected: string m_sSvr; string m_sUser; string m_sPwd; str Ing m_sDB; string m_sUserMode; bool m_bReopen; // The system re-opens the connection int m_nStatus; // 0: SQL idle status 1: SQL statement waiting for execution 2: int m_nCount; // number of records in the result set int m_nCode; // The Returned Code int m_nSQLSize; // The default value is 16 K string m_sErr; // error message char * m_pSQL; // SQL statement string m_sSrc; // call the source bool m_bError; // whether the statement execution has an error int m_nDBType; // The driver type void * m_pUniDBRecv; // retain bool m_bTran; // The transaction flag void * m_pReq; www.2cto.com byte * m_pReqBuf; int m_nReqSiz E; bool m_bDebug ;};# endif //! Defined (afx_embeddedmysql_h1_516724e2_889c_4899_9dae_330cd4c5954f0000included _) by Cai lei