summaryrefslogtreecommitdiff
path: root/src/dal/mysqldataprovider.h
diff options
context:
space:
mode:
authorHuynh Tran <nthuynh75@gmail.com>2005-06-16 17:19:27 +0000
committerHuynh Tran <nthuynh75@gmail.com>2005-06-16 17:19:27 +0000
commit4a33343730f075018cc7c5424335f2137d11619a (patch)
tree59c579b1dbb6edee819a59a65b0c4c1e52878f71 /src/dal/mysqldataprovider.h
parent154515dbaeff0dfb0501f96464a7016945f45fbd (diff)
downloadmanaserv-4a33343730f075018cc7c5424335f2137d11619a.tar.gz
manaserv-4a33343730f075018cc7c5424335f2137d11619a.tar.bz2
manaserv-4a33343730f075018cc7c5424335f2137d11619a.tar.xz
manaserv-4a33343730f075018cc7c5424335f2137d11619a.zip
Simplified APIs, change namespace from tmw to tmwserv, implemented MySQL data provider, added unit tests (require CPPUnit) and bug fixes.
Diffstat (limited to 'src/dal/mysqldataprovider.h')
-rw-r--r--src/dal/mysqldataprovider.h72
1 files changed, 17 insertions, 55 deletions
diff --git a/src/dal/mysqldataprovider.h b/src/dal/mysqldataprovider.h
index 967e9ce2..76194680 100644
--- a/src/dal/mysqldataprovider.h
+++ b/src/dal/mysqldataprovider.h
@@ -21,16 +21,18 @@
*/
-#ifndef _TMW_MYSQL_DATA_PROVIDER_H_
-#define _TMW_MYSQL_DATA_PROVIDER_H_
+#ifndef _TMWSERV_MYSQL_DATA_PROVIDER_H_
+#define _TMWSERV_MYSQL_DATA_PROVIDER_H_
#include <string>
+#include <mysql/mysql.h>
+
#include "dataprovider.h"
-namespace tmw
+namespace tmwserv
{
namespace dal
{
@@ -57,7 +59,7 @@ class MySqlDataProvider: public DataProvider
/**
- * Get the database backend name.
+ * Get the name of the database backend.
*
* @return the database backend name.
*/
@@ -67,22 +69,6 @@ class MySqlDataProvider: public DataProvider
/**
- * Create a new database.
- *
- * @param dbName the database name.
- * @param dbPath the database file path (optional)
- *
- * @exception DbCreationFailure if unsuccessful creation.
- * @exception std::exception if unexpected exception.
- */
- void
- createDb(const std::string& dbName,
- const std::string& dbPath = "")
- throw(DbCreationFailure,
- std::exception);
-
-
- /**
* Create a connection to the database.
*
* @param dbName the database name.
@@ -90,69 +76,45 @@ class MySqlDataProvider: public DataProvider
* @param password the user password.
*
* @exception DbConnectionFailure if unsuccessful connection.
- * @exception std::exception if unexpected exception.
*/
void
connect(const std::string& dbName,
const std::string& userName,
- const std::string& password)
- throw(DbConnectionFailure,
- std::exception);
-
-
- /**
- * Create a connection to the database.
- *
- * @param dbName the database name.
- * @param dbPath the database file path.
- * @param userName the user name.
- * @param password the user password.
- *
- * @exception DbConnectionFailure if unsuccessful connection.
- * @exception std::exception if unexpected exception.
- */
- void
- connect(const std::string& dbName,
- const std::string& dbPath,
- const std::string& userName,
- const std::string& password)
- throw(DbConnectionFailure,
- std::exception);
+ const std::string& password);
/**
* Execute a SQL query.
*
* @param sql the SQL query.
- * @param refresh if true, refresh the cache (optional)
+ * @param refresh if true, refresh the cache (default = false).
*
* @return a recordset.
*
* @exception DbSqlQueryExecFailure if unsuccessful execution.
- * @exception std::exception if unexpected exception.
+ * @exception std::runtime_error if trying to query a closed database.
*/
const RecordSet&
execSql(const std::string& sql,
- const bool refresh = false)
- throw(DbSqlQueryExecFailure,
- std::exception);
+ const bool refresh = false);
/**
* Close the connection to the database.
*
* @exception DbDisconnectionFailure if unsuccessful disconnection.
- * @exception std::exception if unexpected exception.
*/
void
- disconnect(void)
- throw(DbDisconnectionFailure,
- std::exception);
+ disconnect(void);
+
+
+ private:
+ MYSQL* mDb; /**< the handle to the database connection */
};
} // namespace dal
-} // namespace tmw
+} // namespace tmwserv
-#endif // _TMW_MYSQL_DATA_PROVIDER_H_
+#endif // _TMWSERV_MYSQL_DATA_PROVIDER_H_