mysql 嵌入式c_嵌入式MYSQL服务器实现

嵌入式MYSQL服务器实现// EmbeddedMySQL.h: interface for the CEmbeddedMySQL class.#if !defined(AFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_)#defi

嵌入式MYSQL服务器实现

// EmbeddedMySQL.h: interface for the CEmbeddedMySQL class.

//

//

#if !defined(AFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_)

#define AFX_EMBEDDEDMYSQL_H__516724E2_889C_4899_9DAE_330CD4C5954F__INCLUDED_

www.2cto.com

#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

#include <.h>

#include

#include "StdString.h"

using namespace std;

//嵌入式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();

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();

// 获取过程返回值

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;                  // 是否注册了过程返回变量

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_)

作者 蔡磊

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值