Connection.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/ado/Connection.h
22 
23  \brief A class that implements a connection to a ADO database.
24 */
25 
26 #ifndef __TERRALIB_ADO_INTERNAL_CONNECTION_H
27 #define __TERRALIB_ADO_INTERNAL_CONNECTION_H
28 
29 // TerraLib
30 #include "Config.h"
31 
32 // STL
33 #include <cstddef>
34 #include <string>
35 
36 // Boost
37 #include <boost/date_time/posix_time/posix_time_types.hpp>
38 #include <boost/noncopyable.hpp>
39 
40 // ADO
41 #import "msado15.dll" \
42  no_namespace rename("EOF", "EndOfFile")
43 #import "msadox.dll"
44 
45 namespace te
46 {
47  namespace ado
48  {
49 
50  /*!
51  \class Connection
52 
53  \brief A class that implements a connection to a ADO database
54 
55  This class models a physical connection to a ADO data source.
56  It is designed to work with the connection pool.
57 
58  \sa ConnectionPool
59  */
60  class TEADOEXPORT Connection : public boost::noncopyable
61  {
62  public:
63 
64  /*!
65  \brief Constructor.
66 
67  \param conninfo A coonection string as undertood by ADO.
68  \param inuse A marker that tells if the connection is in use or not.
69  */
70  Connection(const std::string& conninfo);
71 
72  /*! \brief Destructor. */
73  ~Connection();
74 
75  /*!
76  \brief It queries the database.
77 
78  \param query A SQL Select command.
79 
80  \return A resultset. The caller of this method will take its ownership.
81 
82  \exception Exception It throws an exception if the query execution fails.
83  */
84  _RecordsetPtr query(const std::string& query, bool connected = false);
85 
86  /*!
87  \brief It executes the given SQL command and throws away the result.
88 
89  \param command Any SQL command.
90 
91  \exception Exception It throws an exception if the query execution fails.
92  */
93  void execute(const std::string& command);
94 
95  bool isValid();
96 
97  /*!
98  \brief It gets the ADO Connection object.
99 
100  \return The ADO Connection object.
101  */
102  _ConnectionPtr getConn() const
103  {
104  return m_conn;
105  }
106 
107  public:
108 
109  _ConnectionPtr m_conn; //!< The ADO real connection handle.
110 
111  friend class ConnectionPool;
112  };
113 
114  } // end namespace ado
115 } // end namespace te
116 
117 
118 #endif // __TERRALIB_ADO_INTERNAL_CONNECTION_H
119 
120 
_ConnectionPtr getConn() const
It gets the ADO Connection object.
Definition: Connection.h:102
#define TEADOEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:130
Configuration flags for the TerraLib ADO Data Access driver.
A class that implements a connection to a ADO database.
Definition: Connection.h:60
URI C++ Library.
_ConnectionPtr m_conn
The ADO real connection handle.
Definition: Connection.h:109