Revert "Remove mysql and oracle resources for anna-ericsson project"
[anna.git] / source / dbms.mysql / Database.cpp
diff --git a/source/dbms.mysql/Database.cpp b/source/dbms.mysql/Database.cpp
new file mode 100644 (file)
index 0000000..9508158
--- /dev/null
@@ -0,0 +1,77 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#include <string.h>
+
+#include <anna/core/tracing/Logger.hpp>
+#include <anna/core/tracing/TraceMethod.hpp>
+
+#include <anna/dbms.mysql/mysql.hpp>
+#include <anna/dbms.mysql/internal/sccs.hpp>
+
+using namespace std;
+using namespace anna;
+using namespace anna::dbms;
+
+mysql::Database::Database(const char* dbmsName, const char* host) :
+  dbms::Database(getClassName(), dbmsName) {
+  a_host = (host == NULL) ? NULL : strdup(host);
+  mysql::sccs::activate();
+}
+
+mysql::Database::Database(const char* componentName, const char* dbmsName, const char* host) :
+  dbms::Database(componentName, dbmsName) {
+  a_host = (host == NULL) ? NULL : strdup(host);
+  mysql::sccs::activate();
+}
+
+void mysql::Database::do_initialize()
+throw(RuntimeException) {
+  LOGMETHOD(TraceMethod tm("anna::dbms::mysql::Database", "do_initialize", ANNA_FILE_LOCATION));
+  dbms::Database::do_initialize();
+}
+
+//----------------------------------------------------------------------------------
+// Libera todos los manejadores asociados a este entorno.
+//----------------------------------------------------------------------------------
+mysql::Database::~Database() {
+  LOGMETHOD(TraceMethod tm("anna::dbms::mysql::Database", "~Database", ANNA_FILE_LOCATION));
+
+  if(a_host != NULL)
+    free(a_host);
+}
+
+dbms::Connection* mysql::Database::allocateConnection(const std::string& name, const char* user, const char* password)
+throw(RuntimeException) {
+  return new Connection(*this, name, user, password);
+}
+
+dbms::Statement* mysql::Database::allocateStatement(const char* name, const std::string& expression, const bool isCritical)
+throw(RuntimeException) {
+  return new Statement(*this, name, expression, isCritical);
+}
+
+dbms::InputBind* mysql::Database::allocateInputBind(const char* name, Data& data)
+throw(RuntimeException) {
+  return new InputBind(name, data);
+}
+
+void mysql::Database::deallocate(dbms::InputBind* inputBind)
+throw() {
+  delete(InputBind*) inputBind;
+}
+
+dbms::OutputBind* mysql::Database::allocateOutputBind(const char* name, Data& data)
+throw(RuntimeException) {
+  return new OutputBind(name, data);
+}
+
+void mysql::Database::deallocate(dbms::OutputBind* outputBind)
+throw() {
+  delete(OutputBind*) outputBind;
+}