diff options
Diffstat (limited to 'cpp/demo/Database')
-rwxr-xr-x | cpp/demo/Database/Oracle/occi/DbTypes.typ | 32 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp | 144 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/OCCIServantLocator.h | 46 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/createTypes.sql | 108 |
4 files changed, 165 insertions, 165 deletions
diff --git a/cpp/demo/Database/Oracle/occi/DbTypes.typ b/cpp/demo/Database/Oracle/occi/DbTypes.typ index f682eb61adc..89a7a2a0a02 100755 --- a/cpp/demo/Database/Oracle/occi/DbTypes.typ +++ b/cpp/demo/Database/Oracle/occi/DbTypes.typ @@ -1,16 +1,16 @@ -# **********************************************************************
-#
-# Copyright (c) 2003-2010 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.
-#
-# **********************************************************************
-#
-# Compile with:
-# ott userid=scott/tiger@orcl code=cpp hfile=DbTypes.h cppfile=DbTypes.cpp
-# mapfile=DbTypesMap.cpp intype=DbTypes.typ outtype=DbTypesOut.typ
-# attraccess=private
-#
-TYPE DEPT_T
-TYPE EMP_T
+# ********************************************************************** +# +# Copyright (c) 2003-2010 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. +# +# ********************************************************************** +# +# Compile with: +# ott userid=scott/tiger@orcl code=cpp hfile=DbTypes.h cppfile=DbTypes.cpp +# mapfile=DbTypesMap.cpp intype=DbTypes.typ outtype=DbTypesOut.typ +# attraccess=private +# +TYPE DEPT_T +TYPE EMP_T diff --git a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp index 58c4148376c..51a014dfb2a 100644 --- a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp +++ b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp @@ -6,75 +6,75 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -
-#include <OCCIServantLocator.h>
-#include <EmpI.h>
-#include <DeptI.h>
-#include <DbTypes.h>
-#include <Util.h>
-#include <occi.h>
-
-using namespace std;
-using namespace oracle::occi;
-
-OCCIServantLocator::OCCIServantLocator(const DeptFactoryIPtr& factory) :
- _factory(factory)
-{}
-
-
-Ice::ObjectPtr
-OCCIServantLocator::locate(const Ice::Current& current, Ice::LocalObjectPtr& cookie)
-{
- ConnectionHolderPtr con = new ConnectionHolder(_factory->getConnectionPool());
- RefAny ref = decodeRef(current.id.name, _factory->getEnv(), con->connection());
-
- try
- {
- //
- // Extract SQL type from target object
- //
- string sqlType = Ref<PObject>(ref)->getSQLTypeName();
-
- //
- // Create and return the servant, used only for this one operation
- //
- if(sqlType.find("EMP_T") != string::npos)
- {
- return new EmpI(ref, con, _factory);
- }
- else if(sqlType.find("DEPT_T") != string::npos)
- {
- return new DeptI(ref, con, _factory);
- }
- else
- {
- return 0;
- }
- }
- catch(const SQLException& sqle)
- {
- if(sqle.getErrorCode() == 21700)
- {
- return 0;
- }
- else
- {
- throw;
- }
- }
-}
-
-void
-OCCIServantLocator::finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&)
-{
- //
- // Nothing to do: if the connection was not yet released, it is released (and the tx rolled back)
- // when the servant's last refcount goes away
- //
-}
-
-void
-OCCIServantLocator::deactivate(const string&)
-{
-}
-
+ +#include <OCCIServantLocator.h> +#include <EmpI.h> +#include <DeptI.h> +#include <DbTypes.h> +#include <Util.h> +#include <occi.h> + +using namespace std; +using namespace oracle::occi; + +OCCIServantLocator::OCCIServantLocator(const DeptFactoryIPtr& factory) : + _factory(factory) +{} + + +Ice::ObjectPtr +OCCIServantLocator::locate(const Ice::Current& current, Ice::LocalObjectPtr& cookie) +{ + ConnectionHolderPtr con = new ConnectionHolder(_factory->getConnectionPool()); + RefAny ref = decodeRef(current.id.name, _factory->getEnv(), con->connection()); + + try + { + // + // Extract SQL type from target object + // + string sqlType = Ref<PObject>(ref)->getSQLTypeName(); + + // + // Create and return the servant, used only for this one operation + // + if(sqlType.find("EMP_T") != string::npos) + { + return new EmpI(ref, con, _factory); + } + else if(sqlType.find("DEPT_T") != string::npos) + { + return new DeptI(ref, con, _factory); + } + else + { + return 0; + } + } + catch(const SQLException& sqle) + { + if(sqle.getErrorCode() == 21700) + { + return 0; + } + else + { + throw; + } + } +} + +void +OCCIServantLocator::finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&) +{ + // + // Nothing to do: if the connection was not yet released, it is released (and the tx rolled back) + // when the servant's last refcount goes away + // +} + +void +OCCIServantLocator::deactivate(const string&) +{ +} + diff --git a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.h b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.h index f1d952b39f3..61fdc9784c4 100644 --- a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.h +++ b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.h @@ -6,26 +6,26 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** -
-#ifndef OCCI_SERVANT_LOCATOR_H
-#define OCCI_SERVANT_LOCATOR_H
-
-#include <DeptFactoryI.h>
-#include <Ice/ServantLocator.h>
-#include <occi.h>
-
-class OCCIServantLocator : public Ice::ServantLocator
-{
-public:
-
- OCCIServantLocator(const DeptFactoryIPtr&);
-
- virtual Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&);
- virtual void finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&);
- virtual void deactivate(const std::string&);
-
-private:
- DeptFactoryIPtr _factory;
-};
-
-#endif
+ +#ifndef OCCI_SERVANT_LOCATOR_H +#define OCCI_SERVANT_LOCATOR_H + +#include <DeptFactoryI.h> +#include <Ice/ServantLocator.h> +#include <occi.h> + +class OCCIServantLocator : public Ice::ServantLocator +{ +public: + + OCCIServantLocator(const DeptFactoryIPtr&); + + virtual Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&); + virtual void finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&); + virtual void deactivate(const std::string&); + +private: + DeptFactoryIPtr _factory; +}; + +#endif diff --git a/cpp/demo/Database/Oracle/occi/createTypes.sql b/cpp/demo/Database/Oracle/occi/createTypes.sql index 82fdc0fc025..3c8422d9764 100644 --- a/cpp/demo/Database/Oracle/occi/createTypes.sql +++ b/cpp/demo/Database/Oracle/occi/createTypes.sql @@ -1,54 +1,54 @@ -Rem
-Rem Copyright (c) 2006 ZeroC, Inc. All rights reserved.
-Rem
-Rem This copy of Ice is licensed to you under the terms described in the
-Rem ICE_LICENSE file included in this distribution.
-
-Rem
-Rem Create object types and views for the DEPT and EMP tables
-Rem
-
-SET ECHO ON
-
-CONNECT scott/tiger@orcl
-
-DROP VIEW EMP_VIEW;
-DROP VIEW DEPT_VIEW;
-DROP TYPE EMP_T;
-DROP TYPE DEPT_T;
-
-CREATE TYPE DEPT_T AS OBJECT(
- DEPTNO NUMBER(2),
- DNAME VARCHAR2(14),
- LOC VARCHAR2(13));
-/
-
-CREATE TYPE EMP_T;
-/
-CREATE TYPE EMP_T AS OBJECT(
- EMPNO NUMBER(4),
- ENAME VARCHAR2(10),
- JOB VARCHAR2(9),
- MGRREF REF EMP_T,
- HIREDATE DATE,
- SAL NUMBER(7,2),
- COMM NUMBER(7,2),
- DEPTREF REF DEPT_T);
-/
-
-CREATE VIEW DEPT_VIEW OF DEPT_T WITH OBJECT IDENTIFIER(DEPTNO)
- AS SELECT DEPTNO, DNAME, LOC FROM DEPT;
-
-Rem
-Rem Need to create the view in two steps since it references itself
-Rem
-CREATE VIEW EMP_VIEW OF EMP_T WITH OBJECT IDENTIFIER(EMPNO)
- AS SELECT EMPNO, ENAME, JOB, NULL, HIREDATE, SAL, COMM,
- MAKE_REF(DEPT_VIEW, DEPTNO) FROM EMP;
-
-CREATE OR REPLACE VIEW EMP_VIEW OF EMP_T WITH OBJECT IDENTIFIER(EMPNO)
- AS SELECT EMPNO, ENAME, JOB, MAKE_REF(EMP_VIEW, MGR), HIREDATE, SAL,
- COMM, MAKE_REF(DEPT_VIEW, DEPTNO) FROM EMP;
-
-COMMIT;
-EXIT
+Rem +Rem Copyright (c) 2006 ZeroC, Inc. All rights reserved. +Rem +Rem This copy of Ice is licensed to you under the terms described in the +Rem ICE_LICENSE file included in this distribution. + +Rem +Rem Create object types and views for the DEPT and EMP tables +Rem + +SET ECHO ON + +CONNECT scott/tiger@orcl + +DROP VIEW EMP_VIEW; +DROP VIEW DEPT_VIEW; +DROP TYPE EMP_T; +DROP TYPE DEPT_T; + +CREATE TYPE DEPT_T AS OBJECT( + DEPTNO NUMBER(2), + DNAME VARCHAR2(14), + LOC VARCHAR2(13)); +/ + +CREATE TYPE EMP_T; +/ +CREATE TYPE EMP_T AS OBJECT( + EMPNO NUMBER(4), + ENAME VARCHAR2(10), + JOB VARCHAR2(9), + MGRREF REF EMP_T, + HIREDATE DATE, + SAL NUMBER(7,2), + COMM NUMBER(7,2), + DEPTREF REF DEPT_T); +/ + +CREATE VIEW DEPT_VIEW OF DEPT_T WITH OBJECT IDENTIFIER(DEPTNO) + AS SELECT DEPTNO, DNAME, LOC FROM DEPT; + +Rem +Rem Need to create the view in two steps since it references itself +Rem +CREATE VIEW EMP_VIEW OF EMP_T WITH OBJECT IDENTIFIER(EMPNO) + AS SELECT EMPNO, ENAME, JOB, NULL, HIREDATE, SAL, COMM, + MAKE_REF(DEPT_VIEW, DEPTNO) FROM EMP; + +CREATE OR REPLACE VIEW EMP_VIEW OF EMP_T WITH OBJECT IDENTIFIER(EMPNO) + AS SELECT EMPNO, ENAME, JOB, MAKE_REF(EMP_VIEW, MGR), HIREDATE, SAL, + COMM, MAKE_REF(DEPT_VIEW, DEPTNO) FROM EMP; + +COMMIT; +EXIT |