emsApplication/applications/emsConfigurer/mysqlutils.h

53 lines
1.1 KiB
C++

#ifndef MYSQLUTILS_H
#define MYSQLUTILS_H
#pragma execution_character_set("utf-8")
#include <string>
#ifdef _USING_QT_MYSQL_CONNECTOR_
#include <QtSql/QSqlDatabase>_
#endif
#ifdef _USING_MYSQL_CONNECTOR_
#include <cppconn/connection.h>
#endif
#ifdef _USING_MYSQL_51_LIB_
#include <WinSock2.h>
#include <mysql.h> //MySQL C API include file
#endif
#include "globalparameters.h"
class MysqlUtils
{
protected:
MysqlUtils();
public:
~MysqlUtils();
static MysqlUtils* getInstance();
void CloseDatabase();
bool OpenDatabase(const std::string& server = "127.0.0.1", int dbport = 3306, const std::string& dbuser = "root", const std::string& dbpasswd = "Hj57471000", const std::string& database="hjems");
int RetrieveTableData(TableData& tbl_data,int retrieve_rows=100);
private:
#ifdef _USING_QT_MYSQL_CONNECTOR_
QSqlDatabase m_DbConnection;
#endif
#ifdef _USING_MYSQL_CONNECTOR_
sql::Connection* m_DbConnection;
#endif
#ifdef _USING_MYSQL_51_LIB_
MYSQL* m_DbConnection;
#endif
static MysqlUtils m_instance;
};
#endif // MYSQLUTILS_H