嵌入式MySQL服务器是怎样实现mysql的呢?大家都懂得嵌入式的含义么?接下来我们将告诉大家如何实现嵌入式的mysql服务器。
嵌入式MYSQL服务器实现
//EmbeddedMySQL.h:interfacefortheCEmbeddedMySQLclass.
//
//////////////////////////////////////////////////////////////////////
#if!defined(AFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_)
#defineAFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_
www.2cto.com
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
#include
#include
#include"StdString.h"
usingnamespacestd;
//嵌入式MYSQL服务器
classCEmbeddedMySQL
{
public:
CEmbeddedMySQL();
virtual~CEmbeddedMySQL();
staticboolStartupEmbeddedServer();
staticvoidShutdownEmbeddedServer();
boolOpen(conststring&svr,conststring&usr,conststring&pwd,conststring&db);
voidClose();
www.2cto.com
boolResetDB();
voidSet(conststring&sField,conststring&sValue);
voidSet(conststring&sField,doubledValue);
voidSet(conststring&sField,longnValue);
voidSet(conststring&sField,intnValue);
voidSet(conststring&sField,BYTE*pBuf,intnLen);
voidSetNull(conststring&sField);
voidregisterOutParameter(conststring&sField,charcType);
//voidSetRecord(conststring&sField,conststring&sTableName,conststring&sTypeName,CStdRecord&Record);
voidCmd(constchar*cmd,...);
boolMore();
longExec();
//boolSelectInto(CStdRecord*pRecord,boolbCreateHead=true);
doubleGetDouble(intid);
doubleGetDouble(conststring&name);
longGETLong(intid);
longGetLong(conststring&name);
stringGet(intid);
stringGet(conststring&name);
stringGetLastErrMsg();
char*GetSql();
boolMoreForUpdate();
boolSetBuffer(intnFieldIndex,BYTE*pBuf,longnSize);
boolSetBuffer(conststring&sField,BYTE*pBuf,longnSize);
boolGetBuffer(conststring&sField,BYTE*pBuf,long&nSize);
boolGetBuffer(intnFieldIndex,BYTE*pBuf,long&nSize);
longGetDataSize(conststring&sField);
longGetDataSize(intnFieldIndex);
longGetActualSize(conststring&sField);
longGetActualSize(intnFieldIndex);
www.2cto.com
voidClearSql();
longGetColIndex(conststring&sField);
stringGetColName(intnFiledIndex);
stringGetColType(intindex);
intGetNumCols();
stringGetHeadScript();
introw_getsize();
boolrow_gethead(string&sHead);
boolrow_more(char*pData,int&nSize);
voidSetAutoCommit(boolautoCommit);
voidRollBack();
voidCommit();
boolIsDead();
boolSetParam(intnType,conststring&sVal);
protected:
voidWriteSQLErrLog();
//获取过程返回值
stringGetStorageProReturnValue(conststring&name);
voidCopyRowData(char*pData,MYSQL_ROWrow);//addedbycailei
CStdStringGetCurTime(time_tnTime=0);
longGetCurDate(time_tnTime=0);
www.2cto.com
MYSQL*m_hMySQL;
MYSQL_RES*m_pRes;
MYSQL_ROWm_Row;
MYSQL_FIELD*m_pFields;
longm_nRowSize;
boolm_bRegParam;//是否注册了过程返回变量
protected:
stringm_sSvr;
stringm_sUser;
stringm_sPwd;
stringm_sDB;
stringm_sUserMode;
boolm_bReopen;//是系统重新打开连接
intm_nStatus;//0:SQL空闲状态1:有SQL语句等待执行2:有结果数据待取出
intm_nCount;//结果集记录数量
intm_nCode;//执行返回码
intm_nSQLSize;//默认是16K
stringm_sErr;//错误消息
char*m_PSQL;//SQL语句
stringm_sSrc;//调用源
boolm_bError;//语句执行是否出错
intm_nDBType;//驱动类型
void*m_pUniDBRecv;//保留
boolm_bTran;//事务标志
void*m_pReq;www.2cto.com
byte*m_pReqBuf;
intm_nReqSize;
boolm_bdebug;
};
#endif//!defined(AFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_)
¥798.00
¥199.00
¥48.00¥180.00
¥199.00
¥29.90
¥48.00¥180.00