Oracle ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
connection.hxx
Go to the documentation of this file.
1 // file : odb/oracle/connection.hxx
2 // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
3 // license : ODB NCUEL; see accompanying LICENSE file
4 
5 #ifndef ODB_ORACLE_CONNECTION_HXX
6 #define ODB_ORACLE_CONNECTION_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <odb/connection.hxx>
11 
12 #include <odb/details/buffer.hxx>
13 #include <odb/details/shared-ptr.hxx>
14 #include <odb/details/unique-ptr.hxx>
15 
16 #include <odb/oracle/version.hxx>
17 #include <odb/oracle/forward.hxx>
18 #include <odb/oracle/query.hxx>
19 #include <odb/oracle/tracer.hxx>
23 
24 #include <odb/oracle/details/export.hxx>
25 
26 namespace odb
27 {
28  namespace oracle
29  {
30  class statement_cache;
31 
32  class connection;
33  typedef details::shared_ptr<connection> connection_ptr;
34 
35  class LIBODB_ORACLE_EXPORT connection: public odb::connection
36  {
37  public:
40 
41  virtual
42  ~connection ();
43 
46 
49  {
50  return db_;
51  }
52 
53  public:
54  virtual transaction_impl*
55  begin ();
56 
57  public:
59 
60  virtual unsigned long long
61  execute (const char* statement, std::size_t length);
62 
63  // Query preparation.
64  //
65  public:
66  template <typename T>
68  prepare_query (const char* name, const char*);
69 
70  template <typename T>
72  prepare_query (const char* name, const std::string&);
73 
74  template <typename T>
76  prepare_query (const char* name, const oracle::query_base&);
77 
78  template <typename T>
80  prepare_query (const char* name, const odb::query_base&);
81 
82  // SQL statement tracing.
83  //
84  public:
86 
87  void
89  {
91  }
92 
93  void
95  {
97  }
98 
100 
101  public:
102  bool
103  failed () const
104  {
105  return failed_;
106  }
107 
108  void
110  {
111  failed_ = true;
112  }
113 
114  public:
115  OCISvcCtx*
117  {
118  return handle_;
119  }
120 
121  OCIError*
123  {
124  return error_;
125  }
126 
127  statement_cache_type&
129  {
130  return *statement_cache_;
131  }
132 
133  details::buffer&
135  {
136  return lob_buffer_;
137  }
138 
139  private:
140  connection (const connection&);
141  connection& operator= (const connection&);
142 
143  private:
144  friend class transaction_impl; // invalidate_results()
145 
146  private:
147  database_type& db_;
148 
149  // It is important that the error_ member is declared before the
150  // handle_ member as handle_ depends on error_ during destruction.
151  //
152  auto_handle<OCIError> error_;
153 
154  auto_handle<OCISvcCtx> handle_;
155  bool failed_;
156 
157  details::unique_ptr<statement_cache_type> statement_cache_;
158  details::buffer lob_buffer_;
159  };
160  }
161 }
162 
163 #include <odb/oracle/connection.ixx>
164 
165 #include <odb/post.hxx>
166 
167 #endif // ODB_ORACLE_CONNECTION_HXX
Definition: transaction-impl.hxx:22
Definition: connection.hxx:35
details::shared_ptr< connection > connection_ptr
Definition: connection.hxx:32
database_type & database()
Definition: connection.hxx:48
tracer_type * tracer() const
Definition: tracer.hxx:20
Definition: query.hxx:165
struct OCISvcCtx OCISvcCtx
Definition: oracle-fwd.hxx:23
OCISvcCtx * handle()
Definition: connection.hxx:116
Definition: auto-handle.hxx:141
void tracer(tracer_type &t)
Definition: connection.hxx:88
oracle::statement_cache statement_cache_type
Definition: connection.hxx:38
statement_cache_type & statement_cache()
Definition: connection.hxx:128
Definition: statement.hxx:28
bool failed() const
Definition: connection.hxx:103
void mark_failed()
Definition: connection.hxx:109
struct OCIError OCIError
Definition: oracle-fwd.hxx:24
void tracer(tracer_type *t)
Definition: connection.hxx:94
details::buffer & lob_buffer()
Definition: connection.hxx:134
Definition: database.hxx:35
oracle::database database_type
Definition: connection.hxx:39
oracle::tracer tracer_type
Definition: connection.hxx:85
unsigned long long execute(const char *statement)
OCIError * error_handle()
Definition: connection.hxx:122
Definition: statement-cache.hxx:29