00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TMWSERV_MYSQL_DATA_PROVIDER_H_
00022 #define _TMWSERV_MYSQL_DATA_PROVIDER_H_
00023
00024
00025 #include <iosfwd>
00026
00027 #ifdef WIN32
00028 #include <winsock2.h>
00029 #endif
00030 #include <mysql/mysql.h>
00031 #include <climits>
00032
00033 #include "dataprovider.h"
00034 #include "common/configuration.hpp"
00035 #include "utils/logger.h"
00036
00037 namespace dal
00038 {
00039
00040
00044 class MySqlDataProvider: public DataProvider
00045 {
00046 public:
00047
00052 enum {
00053 AUTOCOMMIT_OFF = 0,
00054 AUTOCOMMIT_ON = 1
00055 };
00056
00060 MySqlDataProvider(void)
00061 throw();
00062
00063
00067 ~MySqlDataProvider(void)
00068 throw();
00069
00070
00076 DbBackends
00077 getDbBackend(void) const
00078 throw();
00079
00080
00086 void connect();
00087
00088
00100 const RecordSet&
00101 execSql(const std::string& sql,
00102 const bool refresh = false);
00103
00104
00110 void
00111 disconnect(void);
00112
00118 void
00119 beginTransaction(void)
00120 throw (std::runtime_error);
00121
00127 void
00128 commitTransaction(void)
00129 throw (std::runtime_error);
00130
00136 void
00137 rollbackTransaction(void)
00138 throw (std::runtime_error);
00139
00146 const unsigned int
00147 getModifiedRows(void) const;
00148
00155 const unsigned int
00156 getLastId(void) const;
00157
00158 private:
00159
00161 static const std::string CFGPARAM_MYSQL_HOST;
00163 static const std::string CFGPARAM_MYSQL_PORT;
00165 static const std::string CFGPARAM_MYSQL_DB;
00167 static const std::string CFGPARAM_MYSQL_USER;
00169 static const std::string CFGPARAM_MYSQL_PWD;
00170
00172 static const std::string CFGPARAM_MYSQL_HOST_DEF;
00174 static const unsigned int CFGPARAM_MYSQL_PORT_DEF;
00176 static const std::string CFGPARAM_MYSQL_DB_DEF;
00178 static const std::string CFGPARAM_MYSQL_USER_DEF;
00180 static const std::string CFGPARAM_MYSQL_PWD_DEF;
00181
00182
00183 MYSQL* mDb;
00184 };
00185
00186
00187 }
00188
00189 #endif // _TMWSERV_MYSQL_DATA_PROVIDER_H_