#ifndef MYSQLUTILS_H #define MYSQLUTILS_H #include #ifdef _USING_QT_MYSQL_CONNECTOR_ #include _ #endif #ifdef _USING_MYSQL_CONNECTOR_ #include #endif #ifdef _USING_MYSQL_51_LIB_ #include #include // MySQL C API 头文件 #endif 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"); 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