summaryrefslogtreecommitdiff
path: root/cpp/demo/Database/Oracle/occi/Util.h
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2006-08-17 21:26:26 +0000
committerBernard Normier <bernard@zeroc.com>2006-08-17 21:26:26 +0000
commit96ba1e0f0ceece084ec47e80665a0ac90e935493 (patch)
tree65e7d5173090cd1bf1e26d25145e4b63b478cd4b /cpp/demo/Database/Oracle/occi/Util.h
parentRemove debug return (diff)
downloadice-96ba1e0f0ceece084ec47e80665a0ac90e935493.tar.bz2
ice-96ba1e0f0ceece084ec47e80665a0ac90e935493.tar.xz
ice-96ba1e0f0ceece084ec47e80665a0ac90e935493.zip
First cut of OCCI demo
Diffstat (limited to 'cpp/demo/Database/Oracle/occi/Util.h')
-rw-r--r--cpp/demo/Database/Oracle/occi/Util.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/cpp/demo/Database/Oracle/occi/Util.h b/cpp/demo/Database/Oracle/occi/Util.h
new file mode 100644
index 00000000000..af221566569
--- /dev/null
+++ b/cpp/demo/Database/Oracle/occi/Util.h
@@ -0,0 +1,69 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef UTIL_H
+#define UTIL_H
+
+#include <occi.h>
+#include <string>
+
+//
+// Grabs a connection from a connection pool and ensures
+// it's properly released when ConnectionHolder goes out
+// scope
+//
+class ConnectionHolder
+{
+public:
+
+ ConnectionHolder(oracle::occi::StatelessConnectionPool*);
+ ~ConnectionHolder();
+
+ oracle::occi::Connection* connection() const
+ {
+ return _con;
+ }
+
+ void commit();
+ void rollback();
+
+private:
+
+ void release();
+
+ oracle::occi::Connection* _con;
+ oracle::occi::StatelessConnectionPool* _pool;
+};
+
+
+//
+// Create a fresh exception-safe statement
+//
+class StatementHolder
+{
+public:
+ StatementHolder(oracle::occi::Connection*);
+ StatementHolder(ConnectionHolder&);
+ ~StatementHolder();
+
+ oracle::occi::Statement* statement() const
+ {
+ return _stmt;
+ }
+
+private:
+ oracle::occi::Connection* _con;
+ oracle::occi::Statement* _stmt;
+};
+
+
+int decodeName(const std::string&);
+std::string encodeName(int);
+
+#endif