diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-08-10 18:36:30 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-08-10 18:36:30 +0000 |
commit | 667420c66b32e2200fd15c57e108a35d40499d48 (patch) | |
tree | 11c38ec276c28932ce631189954d25472031a2cc /cpp/demo/Database | |
parent | remove redundant batch labels (diff) | |
download | ice-667420c66b32e2200fd15c57e108a35d40499d48.tar.bz2 ice-667420c66b32e2200fd15c57e108a35d40499d48.tar.xz ice-667420c66b32e2200fd15c57e108a35d40499d48.zip |
Oracle Pro*C demo
Diffstat (limited to 'cpp/demo/Database')
-rw-r--r-- | cpp/demo/Database/Oracle/proc/.depend | 9 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Client.cpp | 671 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/CurrentSqlContext.h | 44 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc | 142 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/DeptFactoryI.h | 32 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/DeptFactoryI.pc | 118 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/DeptI.h | 38 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/DeptI.pc | 237 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/EmpI.h | 34 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/EmpI.pc | 168 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/HR.ice | 85 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Makefile | 65 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/README | 29 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Server.pc | 109 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Util.h | 22 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Util.pc | 59 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/config.client | 1 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/config.server | 6 |
18 files changed, 1869 insertions, 0 deletions
diff --git a/cpp/demo/Database/Oracle/proc/.depend b/cpp/demo/Database/Oracle/proc/.depend new file mode 100644 index 00000000000..f9e12aca5ba --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/.depend @@ -0,0 +1,9 @@ +HR.o: HR.cpp ./HR.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Exception.h ../../../../include/IceUtil/Config.h ../../../../include/Ice/Config.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/IceUtil/Shared.h ../../../../include/Ice/Proxy.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/Object.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/Ice/StringConverter.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/ObjectFactory.h ../../../../include/IceUtil/Iterator.h +Client.o: Client.cpp ../../../../include/Ice/Ice.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/IceUtil/Config.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/IceUtil/Exception.h ../../../../include/Ice/Config.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/IceUtil/Shared.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/StringConverter.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/Proxy.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/Object.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./HR.h +CurrentSqlContext.o: CurrentSqlContext.cpp ../../../../include/Ice/Ice.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/IceUtil/Config.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/IceUtil/Exception.h ../../../../include/Ice/Config.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/IceUtil/Shared.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/StringConverter.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/Proxy.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/Object.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./CurrentSqlContext.h ./Util.h +Util.o: Util.cpp ../../../../include/Ice/Ice.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/IceUtil/Config.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/IceUtil/Exception.h ../../../../include/Ice/Config.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/IceUtil/Shared.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/StringConverter.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/Proxy.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/Object.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./HR.h ./Util.h +EmpI.o: EmpI.cpp ./EmpI.h ./HR.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Exception.h ../../../../include/IceUtil/Config.h ../../../../include/Ice/Config.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/IceUtil/Shared.h ../../../../include/Ice/Proxy.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/Object.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/Ice/StringConverter.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ./CurrentSqlContext.h ../../../../include/Ice/Ice.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./Util.h +DeptI.o: DeptI.cpp ./DeptI.h ./HR.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Exception.h ../../../../include/IceUtil/Config.h ../../../../include/Ice/Config.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/IceUtil/Shared.h ../../../../include/Ice/Proxy.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/Object.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/Ice/StringConverter.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ./CurrentSqlContext.h ../../../../include/Ice/Ice.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./Util.h +DeptFactoryI.o: DeptFactoryI.cpp ./DeptFactoryI.h ./HR.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Exception.h ../../../../include/IceUtil/Config.h ../../../../include/Ice/Config.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/IceUtil/Shared.h ../../../../include/Ice/Proxy.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/Object.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/Ice/StringConverter.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ./CurrentSqlContext.h ../../../../include/Ice/Ice.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./Util.h +Server.o: Server.cpp ./EmpI.h ./HR.h ../../../../include/Ice/LocalObjectF.h ../../../../include/Ice/Handle.h ../../../../include/IceUtil/Handle.h ../../../../include/IceUtil/Exception.h ../../../../include/IceUtil/Config.h ../../../../include/Ice/Config.h ../../../../include/Ice/ProxyHandle.h ../../../../include/Ice/ProxyF.h ../../../../include/Ice/ObjectF.h ../../../../include/Ice/GCCountMap.h ../../../../include/Ice/Exception.h ../../../../include/Ice/LocalObject.h ../../../../include/IceUtil/Shared.h ../../../../include/Ice/Proxy.h ../../../../include/IceUtil/Mutex.h ../../../../include/IceUtil/Lock.h ../../../../include/IceUtil/ThreadException.h ../../../../include/Ice/ProxyFactoryF.h ../../../../include/Ice/ConnectionIF.h ../../../../include/Ice/EndpointIF.h ../../../../include/Ice/Endpoint.h ../../../../include/Ice/UndefSysMacros.h ../../../../include/Ice/ObjectAdapterF.h ../../../../include/Ice/ReferenceF.h ../../../../include/Ice/OutgoingAsyncF.h ../../../../include/Ice/Current.h ../../../../include/Ice/ConnectionF.h ../../../../include/Ice/Identity.h ../../../../include/Ice/StreamF.h ../../../../include/Ice/CommunicatorF.h ../../../../include/Ice/Object.h ../../../../include/Ice/GCShared.h ../../../../include/Ice/GCRecMutex.h ../../../../include/IceUtil/RecMutex.h ../../../../include/Ice/IncomingAsyncF.h ../../../../include/Ice/Outgoing.h ../../../../include/IceUtil/Monitor.h ../../../../include/IceUtil/Cond.h ../../../../include/IceUtil/Time.h ../../../../include/Ice/BasicStream.h ../../../../include/Ice/InstanceF.h ../../../../include/Ice/ObjectFactoryF.h ../../../../include/Ice/Buffer.h ../../../../include/Ice/Protocol.h ../../../../include/Ice/StringConverter.h ../../../../include/IceUtil/AutoArray.h ../../../../include/IceUtil/Unicode.h ../../../../include/Ice/Incoming.h ../../../../include/Ice/ServantLocatorF.h ../../../../include/Ice/ServantManagerF.h ../../../../include/Ice/Direct.h ../../../../include/Ice/UserExceptionFactory.h ../../../../include/Ice/FactoryTable.h ../../../../include/Ice/FactoryTableDef.h ../../../../include/IceUtil/StaticMutex.h ../../../../include/Ice/UserExceptionFactoryF.h ./CurrentSqlContext.h ../../../../include/Ice/Ice.h ../../../../include/Ice/GC.h ../../../../include/IceUtil/Thread.h ../../../../include/Ice/Initialize.h ../../../../include/Ice/PropertiesF.h ../../../../include/Ice/LoggerF.h ../../../../include/Ice/StatsF.h ../../../../include/Ice/BuiltinSequences.h ../../../../include/Ice/LocalException.h ../../../../include/Ice/Properties.h ../../../../include/Ice/Logger.h ../../../../include/Ice/LoggerUtil.h ../../../../include/Ice/Stats.h ../../../../include/Ice/Communicator.h ../../../../include/Ice/RouterF.h ../../../../include/Ice/LocatorF.h ../../../../include/Ice/PluginF.h ../../../../include/Ice/ObjectFactory.h ../../../../include/Ice/ObjectAdapter.h ../../../../include/Ice/IncomingAsync.h ../../../../include/Ice/FacetMap.h ../../../../include/Ice/Locator.h ../../../../include/Ice/ProcessF.h ../../../../include/Ice/ServantLocator.h ../../../../include/Ice/OutgoingAsync.h ../../../../include/Ice/Process.h ../../../../include/Ice/Application.h ../../../../include/Ice/Connection.h ../../../../include/Ice/Functional.h ../../../../include/IceUtil/Functional.h ../../../../include/Ice/Stream.h ./DeptI.h ./DeptFactoryI.h +HR.cpp: HR.ice diff --git a/cpp/demo/Database/Oracle/proc/Client.cpp b/cpp/demo/Database/Oracle/proc/Client.cpp new file mode 100644 index 00000000000..af09a5a8de0 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/Client.cpp @@ -0,0 +1,671 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <HR.h> +#include <iostream> + +using namespace std; +using namespace HR; + +class HRClient : public Ice::Application +{ +public: + HRClient(); + + virtual int run(int, char*[]); + + enum Menu {rootMenu, empMenu, deptMenu}; + +private: + + void help() const; + bool checkCin(const string& command) const; + void checkEof(const string& command) const; + void invalidCommand(const string& command) const; + + void doRootMenu(const string&) const; + void doDeptMenu(const string&) const; + void doEmpMenu(const string&) const; + + Menu _currentMenu; + DeptFactoryPrx _factory; + DeptPrx _currentDept; + EmpPrx _currentEmp; + + string _commonCommands; + string _rootCommands; + string _deptCommands; + string _empCommands; +}; + +int +main(int argc, char* argv[]) +{ + HRClient app; + return app.main(argc, argv, "config.client"); +} + +HRClient::HRClient() : + _currentMenu(rootMenu) +{ + _commonCommands = + "dept <identity>: set department <identity> as the current department\n" + "emp <identity>: set employee <identity> as the current employee\n" + "exit: exit client\n" + "help: prints this list of commands\n" + "root: go back to the root menu\n"; + + _rootCommands = + "create: create a new department\n" + "find <name>: find the deparment(s) with the given name\n" + "list: list all departments\n"; + + + _deptCommands = + "create: create a new employee in this department\n" + "find <name>: find employee(s) named <name> in this department\n" + "list: list all employees in this department\n" + "remove: remove this department\n" + "show: describe this department\n" + "update: update this department\n"; + + _empCommands = + "remove: remove this employee\n" + "show: describe this employee\n" + "update: update this employee\n"; +} + +void +HRClient::checkEof(const string& command) const +{ + if(!cin.eof()) + { + string extra; + getline(cin, extra); + if(extra.size() > 0) + { + cout << "Warning: ignoring extra args '" << extra + << "' for '" << command << "'" << endl; + } + } +} + +bool +HRClient::checkCin(const string& command) const +{ + if(!cin) + { + cout << "Error: failed to read arguments for '" << command << "'" << endl; + cin.clear(); + cin.ignore(numeric_limits<streamsize>::max(), '\n'); + return false; + } + checkEof(command); + return true; +} + +void +HRClient::invalidCommand(const string& command) const +{ + cout << "Invalid command '" << command << "'" << endl; + cin.ignore(numeric_limits<streamsize>::max(), '\n'); +} + +void +HRClient::help() const +{ + cout << "Commands are:\n"; + cout << "--- Specific to this menu ---\n"; + + switch(_currentMenu) + { + case rootMenu: + { + cout << _rootCommands; + break; + } + case deptMenu: + { + cout << _deptCommands; + break; + } + case empMenu: + { + cout << _empCommands; + break; + } + } + cout << "--- Common to all menus ---\n"; + cout << _commonCommands << endl; +} + +int +HRClient::run(int argc, char* argv[]) +{ + Ice::PropertiesPtr properties = communicator()->getProperties(); + const string proxyProperty = "HR.DeptFactory"; + std::string proxy = properties->getProperty(proxyProperty); + if(proxy.empty()) + { + cerr << argv[0] << ": property `" << proxyProperty << "' not set" << endl; + return EXIT_FAILURE; + } + + Ice::ObjectPrx base = communicator()->stringToProxy(proxy); + _factory = DeptFactoryPrx::checkedCast(base); + if(_factory == 0) + { + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; + } + + Ice::EndpointSeq endpoints = _factory->ice_getEndpoints(); + + + // + // cin loop + // + + string command; + + do + { + cout << "==> "; + cin >> command; + + if(!cin) + { + break; + } + + // + // Common commands + // + if(command == "dept") + { + string identity; + cin >> identity; + if(checkCin(command)) + { + _currentMenu = deptMenu; + _currentDept = DeptPrx::uncheckedCast( + communicator()->stringToProxy(identity)->ice_endpoints(endpoints)); + } + } + else if(command == "emp") + { + string identity; + cin >> identity; + if(checkCin(command)) + { + _currentMenu = empMenu; + _currentEmp = EmpPrx::uncheckedCast( + communicator()->stringToProxy(identity)->ice_endpoints(endpoints)); + } + } + else if(command == "exit") + { + checkEof(command); + break; + } + else if(command == "help") + { + checkEof(command); + help(); + } + else if(command == "root") + { + checkEof(command); + _currentMenu = rootMenu; + } + else if(_currentMenu == rootMenu) + { + doRootMenu(command); + } + else if(_currentMenu == deptMenu) + { + doDeptMenu(command); + } + else if(_currentMenu == empMenu) + { + doEmpMenu(command); + } + else + { + assert(0); + } + } + while(cin.good()); + + return EXIT_SUCCESS; +} + +void +HRClient::doRootMenu(const string& command) const +{ + if(command == "create") + { + checkEof(command); + cout << "Please enter: deptno dname loc ==> "; + int deptno; + DeptDesc desc; + cin >> deptno >> desc.dname >> desc.loc; + if(checkCin("create parameters")) + { + try + { + _factory->createDept(deptno, desc); + cout << "Created new department number " << deptno << endl; + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + } + else if(command == "find") + { + string name; + cin >> name; + if(checkCin(command)) + { + DeptPrxSeq depts; + try + { + depts = _factory->findByName(name); + if(depts.size() == 0) + { + cout << "<None found>" << endl; + } + else + { + for(DeptPrxSeq::iterator p = depts.begin(); p != depts.end(); ++p) + { + cout << communicator()->identityToString((*p)->ice_getIdentity()) << endl; + } + } + + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + } + else if(command == "list") + { + checkEof(command); + DeptPrxSeq depts; + try + { + depts = _factory->findAll(); + if(depts.size() == 0) + { + cout << "<None found>" << endl; + } + else + { + for(DeptPrxSeq::iterator p = depts.begin(); p != depts.end(); ++p) + { + cout << communicator()->identityToString((*p)->ice_getIdentity()) << endl; + } + } + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + else + { + invalidCommand(command); + } +} + +void +HRClient::doDeptMenu(const string& command) const +{ + if(command == "create") + { + checkEof(command); + cout << "Please enter: empno ename job mgr hiredate sal comm ==> "; + int empno; + string mgrId; + EmpDesc desc; + cin >> empno >> desc.ename >> desc.job >> mgrId >> desc.hiredate >> desc.sal >> desc.comm; + if(mgrId != "<None>") + { + desc.mgr = EmpPrx::uncheckedCast(communicator() + ->stringToProxy(mgrId)->ice_endpoints( + _factory->ice_getEndpoints())); + } + desc.edept = _currentDept; + + if(checkCin("create parameters")) + { + try + { + _currentDept->createEmp(empno, desc); + cout << "Created new employee number " << empno << endl; + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + } + else if(command == "find") + { + string name; + cin >> name; + if(checkCin(command)) + { + EmpPrxSeq emps; + try + { + emps = _currentDept->findByName(name); + if(emps.size() == 0) + { + cout << "<None found>" << endl; + } + else + { + for(EmpPrxSeq::iterator p = emps.begin(); p != emps.end(); ++p) + { + cout << communicator()->identityToString((*p)->ice_getIdentity()) << endl; + } + } + + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + } + else if(command == "list") + { + checkEof(command); + EmpPrxSeq emps; + try + { + emps = _currentDept->findAll(); + if(emps.size() == 0) + { + cout << "<None found>" << endl; + } + else + { + for(EmpPrxSeq::iterator p = emps.begin(); p != emps.end(); ++p) + { + cout << communicator()->identityToString((*p)->ice_getIdentity()) << endl; + } + } + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + else if(command == "remove") + { + checkEof(command); + try + { + _currentDept->remove(); + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + else if(command == "show") + { + checkEof(command); + try + { + DeptDesc desc = _currentDept->getDesc(); + cout << "identity: " << communicator()->identityToString( + _currentDept->ice_getIdentity()) << endl; + cout << "dname: " << desc.dname << endl; + cout << "loc: " << desc.loc << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + else if(command == "update") + { + checkEof(command); + cout << "Please enter: dname loc ==> "; + DeptDesc desc; + cin >> desc.dname >> desc.loc; + if(checkCin("update parameters")) + { + try + { + _currentDept->updateDesc(desc); + cout << "Department updated" << endl; + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + } + else + { + invalidCommand(command); + } +} + +void +HRClient::doEmpMenu(const string& command) const +{ + if(command == "remove") + { + checkEof(command); + try + { + _currentEmp->remove(); + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + else if(command == "show") + { + checkEof(command); + try + { + EmpDesc desc = _currentEmp->getDesc(); + cout << "identity: " << communicator()->identityToString( + _currentEmp->ice_getIdentity()) << endl; + cout << "ename: " << desc.ename << endl; + cout << "job: " << desc.job << endl; + cout << "mgr: " << (desc.mgr == 0 ? "<None>" : + communicator()->identityToString( + desc.mgr->ice_getIdentity())) << endl; + cout << "hiredate: " << desc.hiredate << endl; + cout << "sal: " << desc.sal << endl; + cout << "comm: " << desc.comm << endl; + cout << "dept: " << (desc.edept == 0 ? "<None>" : + communicator()->identityToString( + desc.edept->ice_getIdentity())) << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + else if(command == "update") + { + checkEof(command); + cout << "Please enter: ename job mgr hiredate sal comm dept ==> "; + EmpDesc desc; + string mgrId; + string deptId; + cin >> desc.ename >> desc.job + >> mgrId >> desc.hiredate >> desc.sal >> desc.comm >> deptId; + + if(mgrId != "<None>") + { + desc.mgr = EmpPrx::uncheckedCast(communicator() + ->stringToProxy(mgrId)->ice_endpoints( + _factory->ice_getEndpoints())); + } + + if(deptId != "<None>") + { + desc.edept = DeptPrx::uncheckedCast(communicator() + ->stringToProxy(deptId)->ice_endpoints( + _factory->ice_getEndpoints())); + } + + if(checkCin("update parameters")) + { + try + { + _currentEmp->updateDesc(desc); + cout << "Employee updated" << endl; + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } + } + } + else + { + invalidCommand(command); + } +} diff --git a/cpp/demo/Database/Oracle/proc/CurrentSqlContext.h b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.h new file mode 100644 index 00000000000..acc8bfe58d7 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.h @@ -0,0 +1,44 @@ +// ********************************************************************** +// +// 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 CURRENT_SQL_CONTEXT_H +#define CURRENT_SQL_CONTEXT_H + +#include <Ice/Ice.h> + +// +// Provides a sql_context for each thread created by the communicator(s) +// using the associated thread-notification object +// + +// +// Note: sql_context is defined in Pro*C -generated code, so this +// header can only be included in .pc files. +// + +class CurrentSqlContext +{ +public: + + CurrentSqlContext(const std::string&); + + // + // Default copy ctor and assignment operator ok + // + + Ice::ThreadNotificationPtr getHook() const; + operator sql_context() const; + +private: + const std::string _connectInfo; + size_t _index; + Ice::ThreadNotificationPtr _hook; +}; + +#endif diff --git a/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc new file mode 100644 index 00000000000..d17b1a3b019 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc @@ -0,0 +1,142 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <CurrentSqlContext.h> +#include <sqlca.h> +#include <Util.h> + +using namespace std; + + +#ifdef _MSC_VER + #define __thread __declspec(thread) +#endif + +namespace +{ + +// +// Each CurrentSqlContext object gets its own slot (index) in the vector +// (and there is a separate vector in each thread) +// +__thread std::vector<sql_context>* _current = 0; +size_t _currentIndex = 0; + + +class Notification : public Ice::ThreadNotification +{ +public: + + Notification(size_t index) : + _index(index) + { + } + + virtual void start() + { + } + + virtual void stop() + { + if(_current != 0 && _index < _current->size()) + { + cerr << "Disconnecting from Oracle in thread " << IceUtil::ThreadControl().id() << endl; + + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = (*_current)[_index]; + EXEC SQL END DECLARE SECTION; + + if(ctx != 0) + { + (*_current)[_index] = 0; + EXEC SQL CONTEXT USE :ctx; + + struct sqlca sqlca; + EXEC SQL ROLLBACK RELEASE; + EXEC SQL CONTEXT FREE :ctx; + } + + if(find_if(_current->begin(), _current->end(), bind2nd(not_equal_to<sql_context>(), static_cast<void*>(0))) + == _current->end()) + { + cerr << "Deleting _current in thread " << IceUtil::ThreadControl().id() << endl; + delete _current; + _current = 0; + } + } + } + +private: + const size_t _index; +}; + + +} + +CurrentSqlContext::CurrentSqlContext(const string& connectInfo) : + _connectInfo(connectInfo) +{ + { + IceUtil::StaticMutex::Lock lock(IceUtil::globalMutex); + _index = _currentIndex++; + } + _hook = new Notification(_index); +} + +Ice::ThreadNotificationPtr +CurrentSqlContext::getHook() const +{ + return _hook; +} + +CurrentSqlContext::operator sql_context() const +{ + if(_current == 0) + { + _current = new std::vector<sql_context>(_index + 1); + } + if(_index >= _current->size()) + { + _current->resize(_index + 1); + } + + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = (*_current)[_index]; + const char* connectInfo = _connectInfo.c_str(); + EXEC SQL END DECLARE SECTION; + + EXEC SQL WHENEVER SQLERROR DO handleSqlError(sqlca, ctx); + + if(ctx == 0) + { + cerr << "Connecting to Oracle in thread " << IceUtil::ThreadControl().id() << endl; + + // + // Allocate and connect + // + struct sqlca sqlca; + + EXEC SQL CONTEXT ALLOCATE :ctx; + EXEC SQL CONTEXT USE :ctx; + EXEC SQL CONNECT :connectInfo; + + (*_current)[_index] = ctx; + } + + return ctx; + +} + + + + + + + diff --git a/cpp/demo/Database/Oracle/proc/DeptFactoryI.h b/cpp/demo/Database/Oracle/proc/DeptFactoryI.h new file mode 100644 index 00000000000..a32f981c832 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/DeptFactoryI.h @@ -0,0 +1,32 @@ +// ********************************************************************** +// +// 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 DEPT_FACTORYI_H +#define DEPT_FACTORYI_H + +#include <HR.h> +#include <CurrentSqlContext.h> + +class DeptFactoryI : public HR::DeptFactory +{ +public: + + DeptFactoryI(const CurrentSqlContext&, const std::string&); + + virtual HR::DeptPrx createDept(int, const HR::DeptDesc&, const Ice::Current&); + + virtual HR::DeptPrxSeq findAll(const Ice::Current&); + virtual HR::DeptPrxSeq findByName(const std::string&, const Ice::Current&); + +private: + const CurrentSqlContext _currentCtx; + const std::string _deptCategory; +}; + +#endif diff --git a/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc b/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc new file mode 100644 index 00000000000..16119d6536b --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc @@ -0,0 +1,118 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <DeptFactoryI.h> +#include <Util.h> +#include <sqlca.h> + +EXEC SQL WHENEVER SQLERROR DO handleSqlError(sqlca, ctx); + +using namespace std; + + +DeptFactoryI::DeptFactoryI(const CurrentSqlContext& currentCtx, const string& deptCategory) : + _currentCtx(currentCtx), + _deptCategory(deptCategory) +{ +} + +HR::DeptPrx +DeptFactoryI::createDept(int key, const HR::DeptDesc& desc, const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int deptno = key; + const char* dname = desc.dname.c_str(); + const char* loc = desc.loc.c_str(); + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL INSERT INTO DEPT(deptno, dname, loc) + VALUES(:deptno, :dname, :loc); + EXEC SQL COMMIT; + + Ice::Identity deptId; + deptId.name = encodeName(deptno); + deptId.category = _deptCategory; + return HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); +} + +HR::DeptPrxSeq +DeptFactoryI::findAll(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int deptno; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL DECLARE depCursor1 CURSOR FOR SELECT DEPTNO FROM DEPT; + EXEC SQL OPEN depCursor1; + + EXEC SQL WHENEVER NOT FOUND DO BREAK; + + HR::DeptPrxSeq result; + + for(;;) + { + EXEC SQL FETCH depCursor1 INTO :deptno; + + Ice::Identity deptId; + deptId.category = _deptCategory; + deptId.name = encodeName(deptno); + + result.push_back( + HR::DeptPrx::uncheckedCast( + current.adapter->createProxy(deptId))); + } + + EXEC SQL CLOSE depCursor1; + EXEC SQL COMMIT; + return result; +} + + +HR::DeptPrxSeq +DeptFactoryI::findByName(const string& name, const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + const char* dname = name.c_str(); + sql_context ctx = _currentCtx; + int deptno; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL DECLARE depCursor2 CURSOR FOR SELECT DEPTNO FROM DEPT + WHERE DNAME = :dname; + EXEC SQL OPEN depCursor2; + + EXEC SQL WHENEVER NOT FOUND DO BREAK; + + HR::DeptPrxSeq result; + + for(;;) + { + EXEC SQL FETCH depCursor2 INTO :deptno; + + Ice::Identity deptId; + deptId.category = _deptCategory; + deptId.name = encodeName(deptno); + + result.push_back( + HR::DeptPrx::uncheckedCast( + current.adapter->createProxy(deptId))); + } + + EXEC SQL CLOSE depCursor2; + EXEC SQL COMMIT; + return result; +} diff --git a/cpp/demo/Database/Oracle/proc/DeptI.h b/cpp/demo/Database/Oracle/proc/DeptI.h new file mode 100644 index 00000000000..57ab29e932b --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/DeptI.h @@ -0,0 +1,38 @@ +// ********************************************************************** +// +// 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 DEPTI_H +#define DEPTI_H + +#include <HR.h> +#include <CurrentSqlContext.h> + +class DeptI : public HR::Dept +{ +public: + + DeptI(const CurrentSqlContext&, const std::string&); + + virtual void ice_ping(const Ice::Current&); + + virtual HR::EmpPrx createEmp(int, const HR::EmpDesc&, const Ice::Current&); + + virtual HR::DeptDesc getDesc(const Ice::Current&); + virtual void updateDesc(const HR::DeptDesc& newDesc, const Ice::Current&); + virtual void remove(const Ice::Current&); + + virtual HR::EmpPrxSeq findAll(const Ice::Current&); + virtual HR::EmpPrxSeq findByName(const std::string&, const Ice::Current&); + +private: + const CurrentSqlContext _currentCtx; + const std::string _empCategory; +}; + +#endif diff --git a/cpp/demo/Database/Oracle/proc/DeptI.pc b/cpp/demo/Database/Oracle/proc/DeptI.pc new file mode 100644 index 00000000000..87040476194 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/DeptI.pc @@ -0,0 +1,237 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <DeptI.h> +#include <Util.h> +#include <sqlca.h> + +EXEC SQL WHENEVER SQLERROR DO handleSqlError(sqlca, ctx); + +using namespace std; + + +DeptI::DeptI(const CurrentSqlContext& currentCtx, const string& empCategory) : + _currentCtx(currentCtx), + _empCategory(empCategory) +{ +} + +void +DeptI::ice_ping(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int deptno = decodeName(current.id.name); + int count = 0; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL SELECT COUNT(*) INTO :count FROM DEPT WHERE DEPTNO = :deptno; + EXEC SQL COMMIT; + + if(count == 0) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } +} + +HR::EmpPrx +DeptI::createEmp(int key, const HR::EmpDesc& desc, const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int deptno = decodeName(current.id.name); + int empno = key; + const char* ename = desc.ename.c_str(); + const char* job = desc.job.c_str(); + int mgr = 0; + short mgrInd = 0; + const char* hiredate = desc.hiredate.c_str(); + const char* sal = desc.sal.c_str(); + const char* comm = desc.comm.c_str(); + // + // We ignore desc.dept + // + EXEC SQL END DECLARE SECTION; + + if(desc.mgr == 0) + { + // + // mgr is NULL + // + mgrInd = -1; + } + else + { + mgr = decodeName(desc.mgr->ice_getIdentity().name); + } + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL INSERT INTO EMP(empno, ename, job, mgr, hiredate, sal, comm, deptno) + VALUES(:empno, :ename, :job, :mgr:mgrInd, :hiredate, :sal, :comm, :deptno); + EXEC SQL COMMIT; + + + Ice::Identity empId; + empId.name = encodeName(empno); + empId.category = _empCategory; + return HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId)); +} + +HR::DeptDesc +DeptI::getDesc(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + int deptno = decodeName(current.id.name); + sql_context ctx = _currentCtx; + char dname[15]; + char loc[14]; + short dnameInd; + short locInd; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL SELECT DNAME, LOC + INTO :dname:dnameInd, :loc:locInd + FROM DEPT WHERE DEPTNO = :deptno; + EXEC SQL COMMIT; + + HR::DeptDesc result; + if(dnameInd >= 0) + { + // + // Should log a warning if > 0! + // + result.dname = dname; + } + // + // else null + // + + if(locInd >= 0) + { + // + // Should log a warning if > 0! + // + result.loc = loc; + } + // + // else null + // + + return result; +} + +void DeptI::updateDesc(const HR::DeptDesc& newDesc, const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + int deptno = decodeName(current.id.name); + sql_context ctx = _currentCtx; + const char* dname = newDesc.dname.c_str(); + const char* loc = newDesc.loc.c_str(); + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL UPDATE DEPT + SET DNAME = :dname, LOC = :loc + WHERE DEPTNO = :deptno; + EXEC SQL COMMIT; +} + +void DeptI::remove(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + int deptno = decodeName(current.id.name); + sql_context ctx = _currentCtx; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL DELETE FROM DEPT WHERE DEPTNO = :deptno; + EXEC SQL COMMIT; +} + +HR::EmpPrxSeq +DeptI::findAll(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + int deptno = decodeName(current.id.name); + sql_context ctx = _currentCtx; + int empno; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL DECLARE empCursor1 CURSOR FOR SELECT EMPNO FROM EMP WHERE DEPTNO = :deptno; + EXEC SQL OPEN empCursor1; + + EXEC SQL WHENEVER NOT FOUND DO BREAK; + + HR::EmpPrxSeq result; + + for(;;) + { + EXEC SQL FETCH empCursor1 INTO :empno; + + Ice::Identity empId; + empId.category = _empCategory; + empId.name = encodeName(empno); + + result.push_back( + HR::EmpPrx::uncheckedCast( + current.adapter->createProxy(empId))); + } + + EXEC SQL CLOSE empCursor1; + EXEC SQL COMMIT; + return result; +} + + +HR::EmpPrxSeq +DeptI::findByName(const string& name, const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + int deptno = decodeName(current.id.name); + const char* ename = name.c_str(); + sql_context ctx = _currentCtx; + int empno; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL DECLARE empCursor2 CURSOR FOR SELECT EMPNO FROM EMP + WHERE DEPTNO = :deptno AND ENAME = :ename; + EXEC SQL OPEN empCursor2; + + EXEC SQL WHENEVER NOT FOUND DO BREAK; + + HR::EmpPrxSeq result; + + for(;;) + { + EXEC SQL FETCH empCursor2 INTO :empno; + + Ice::Identity empId; + empId.category = _empCategory; + empId.name = encodeName(empno); + + result.push_back( + HR::EmpPrx::uncheckedCast( + current.adapter->createProxy(empId))); + } + + EXEC SQL CLOSE empCursor2; + EXEC SQL COMMIT; + return result; +} diff --git a/cpp/demo/Database/Oracle/proc/EmpI.h b/cpp/demo/Database/Oracle/proc/EmpI.h new file mode 100644 index 00000000000..3e0c7a36719 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/EmpI.h @@ -0,0 +1,34 @@ +// ********************************************************************** +// +// 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 EMPI_H +#define EMPI_H + +#include <HR.h> +#include <CurrentSqlContext.h> + +class EmpI : public HR::Emp +{ +public: + + EmpI(const CurrentSqlContext&, const std::string&, const std::string&); + + virtual void ice_ping(const Ice::Current&); + + virtual HR::EmpDesc getDesc(const Ice::Current&); + virtual void updateDesc(const HR::EmpDesc& newDesc, const Ice::Current&); + virtual void remove(const Ice::Current&); + +private: + const CurrentSqlContext _currentCtx; + const std::string _empCategory; + const std::string _deptCategory; +}; + +#endif diff --git a/cpp/demo/Database/Oracle/proc/EmpI.pc b/cpp/demo/Database/Oracle/proc/EmpI.pc new file mode 100644 index 00000000000..6eb8c6b2c09 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/EmpI.pc @@ -0,0 +1,168 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <EmpI.h> +#include <Util.h> +#include <sqlca.h> + +EXEC SQL WHENEVER SQLERROR DO handleSqlError(sqlca, ctx); + +using namespace std; + + +EmpI::EmpI(const CurrentSqlContext& currentCtx, + const string& empCategory, const string& deptCategory) : + _currentCtx(currentCtx), + _empCategory(empCategory), _deptCategory(deptCategory) +{ +} + +void +EmpI::ice_ping(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int empno = decodeName(current.id.name); + int count = 0; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL SELECT COUNT(*) INTO :count FROM EMP WHERE EMPNO = :empno; + EXEC SQL COMMIT; + + if(count == 0) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } +} + + +HR::EmpDesc +EmpI::getDesc(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int empno = decodeName(current.id.name); + char ename[21]; + short enameInd; + char job[10]; + short jobInd; + int mgr; + short mgrInd; + char hiredate[30]; + short hiredateInd; + char sal[11]; + short salInd; + char comm[11]; + short commInd; + int deptno; + short deptnoInd; + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL SELECT ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO + INTO :ename:enameInd, :job:jobInd, :mgr:mgrInd, + :hiredate:hiredateInd, :sal:salInd, :comm:commInd, :deptno:deptnoInd + FROM EMP WHERE EMPNO = :empno; + EXEC SQL COMMIT; + + HR::EmpDesc result; + if(enameInd >= 0) + { + result.ename = ename; + } + if(jobInd >= 0) + { + result.job = job; + } + if(mgrInd >= 0) + { + Ice::Identity mgrId; + mgrId.name = encodeName(mgr); + mgrId.category = _empCategory; + result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); + } + if(hiredateInd >= 0) + { + result.hiredate = hiredate; + } + if(salInd >= 0) + { + result.sal = sal; + } + if(commInd >= 0) + { + result.comm = comm; + } + if(deptnoInd >= 0) + { + Ice::Identity deptId; + deptId.name = encodeName(deptno); + deptId.category = _deptCategory; + result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + } + return result; +} + +void EmpI::updateDesc(const HR::EmpDesc& newDesc, const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int empno = decodeName(current.id.name); + const char* ename = newDesc.ename.c_str(); + const char* job = newDesc.job.c_str(); + int mgr = 0; + short mgrInd = 0; + const char* hiredate = newDesc.hiredate.c_str(); + const char* sal = newDesc.sal.c_str(); + const char* comm = newDesc.comm.c_str(); + int deptno = 0; + short deptnoInd = 0; + EXEC SQL END DECLARE SECTION; + if(newDesc.mgr == 0) + { + mgrInd = -1; + } + else + { + mgr = decodeName(newDesc.mgr->ice_getIdentity().name); + } + if(newDesc.edept == 0) + { + deptnoInd = -1; + } + else + { + deptno = decodeName(newDesc.edept->ice_getIdentity().name); + } + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL UPDATE EMP + SET ENAME = :ename, JOB = :job, MGR = :mgr:mgrInd, HIREDATE = :hiredate, + SAL = :sal, COMM = :comm, DEPTNO = :deptno:deptnoInd + WHERE EMPNO = :empno; + EXEC SQL COMMIT; +} + +void EmpI::remove(const Ice::Current& current) +{ + struct sqlca sqlca; + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = _currentCtx; + int empno = decodeName(current.id.name); + EXEC SQL END DECLARE SECTION; + + EXEC SQL CONTEXT USE :ctx; + EXEC SQL DELETE FROM EMP WHERE EMPNO = :empno; + EXEC SQL COMMIT; +} + diff --git a/cpp/demo/Database/Oracle/proc/HR.ice b/cpp/demo/Database/Oracle/proc/HR.ice new file mode 100644 index 00000000000..7053cb549a4 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/HR.ice @@ -0,0 +1,85 @@ +// ********************************************************************** +// +// 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 HR_ICE +#define HR_ICE + +// +// Corresponds to the well-known Dept/Emp Oracle demo database. +// See rdbms/admin/utlsamp.sql +// + + +module HR +{ + +interface Dept; +sequence<Dept*> DeptPrxSeq; + +interface Emp; +sequence<Emp*> EmpPrxSeq; + +exception SqlException +{ + string reason; +}; + +// +// The data we maintain about each department +// +struct DeptDesc +{ + string dname; + string loc; +}; + +// +// The data we maintain about each Employee +// +struct EmpDesc +{ + string ename; + string job; + Emp* mgr; + string hiredate; + string sal; + string comm; + Dept* edept; +}; + +interface Emp +{ + idempotent EmpDesc getDesc(); + idempotent void updateDesc(EmpDesc newDesc) throws SqlException; + void remove(); +}; + +interface Dept +{ + Emp* createEmp(int empno, EmpDesc descx) throws SqlException; + + idempotent DeptDesc getDesc(); + idempotent void updateDesc(DeptDesc newDesc) throws SqlException; + void remove() throws SqlException; + + idempotent EmpPrxSeq findAll(); + idempotent EmpPrxSeq findByName(string ename); +}; + +interface DeptFactory +{ + Dept* createDept(int deptno, DeptDesc desc) throws SqlException; + + idempotent DeptPrxSeq findAll(); + idempotent DeptPrxSeq findByName(string dname); +}; + +}; + +#endif diff --git a/cpp/demo/Database/Oracle/proc/Makefile b/cpp/demo/Database/Oracle/proc/Makefile new file mode 100644 index 00000000000..57273815680 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/Makefile @@ -0,0 +1,65 @@ +# ********************************************************************** +# +# 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. +# +# ********************************************************************** + +top_srcdir = ../../../.. + +CLIENT = client +SERVER = server + +TARGETS = $(CLIENT) $(SERVER) + +SLICE_SRCS = HR.ice + +PROC_SRCS = CurrentSqlContext.pc \ + Util.pc \ + EmpI.pc \ + DeptI.pc \ + DeptFactoryI.pc \ + Server.pc + +OBJS = HR.o + +COBJS = Client.o + +SOBJS = $(PROC_SRCS:.pc=.o) + +SRCS = $(OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) + + + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I$(ORACLE_HOME)/precomp/public -DSQLCA_NONE $(CPPFLAGS) + +GENERATED_PROC_FILES = $(PROC_SRCS:.pc=.cpp) + +ORACLE_LIBS = -L$(ORACLE_HOME)/lib -lclntsh + + +.SUFFIXES: +.SUFFIXES: .pc .cpp .c .o + +.pc.cpp: + proc threads=yes parse=none lines=yes code=cpp cpp_suffix=cpp close_on_commit=yes $< + rm tp* *.lis + +$(CLIENT): $(OBJS) $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(COBJS) $(LIBS) + +$(SERVER): $(OBJS) $(SOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SOBJS) $(ORACLE_LIBS) $(LIBS) + +clean:: + rm -f $(GENERATED_PROC_FILES) + +include .depend diff --git a/cpp/demo/Database/Oracle/proc/README b/cpp/demo/Database/Oracle/proc/README new file mode 100644 index 00000000000..841df4a387c --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/README @@ -0,0 +1,29 @@ +Oracle Pro*C/C++ demo +===================== + +This demo shows how to implement an Ice server that uses Oracle +through its Embedded SQL (Pro*C/C++) API. + +It is a fairly simple demo that illustrates how to: + - map relational data to Ice objects, in particular convert + between Ice and Oracle Pro*C/C++ types. + - associate an Oracle Pro*C/C++ context and database connection + to each thread in the Ice server thread pool. + - use Ice default servants + +Pre-requisites +-------------- +- Setup an Oracle database with the traditional EMP/DEPT schema. +With Oracle server 10.2, the corresponding SQL script is +$ORACLE_HOME/rdbms/admin/utilsamp.sql. + +- Review/edit the Oracle.ConnectInfo property in config.server +You may need to change it to connect to your Oracle instance. + +Running the demo +---------------- +- Start the server: +$ server + +- Start the client in a separate terminal: +$ client diff --git a/cpp/demo/Database/Oracle/proc/Server.pc b/cpp/demo/Database/Oracle/proc/Server.pc new file mode 100644 index 00000000000..f3551bbcda4 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/Server.pc @@ -0,0 +1,109 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + + +#include <EmpI.h> +#include <DeptI.h> +#include <DeptFactoryI.h> +#include <Ice/Application.h> +#include <Ice/ServantLocator.h> +#include <sqlca.h> + +using namespace std; + +class HRServer : public Ice::Application +{ +public: + + HRServer(const CurrentSqlContext&); + + virtual int run(int, char*[]); + +private: + CurrentSqlContext _currentCtx; +}; + +class DefaultServantLocator : public Ice::ServantLocator +{ +public: + + DefaultServantLocator(const Ice::ObjectPtr& servant) : + _servant(servant) + { + } + + virtual Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&) + { + return _servant; + } + + virtual void finished(const Ice::Current& curr, + const Ice::ObjectPtr& servant, + const Ice::LocalObjectPtr& cookie) + { + } + + virtual void deactivate(const std::string&) + { + } + +private: + Ice::ObjectPtr _servant; +}; + + +int +main(int argc, char* argv[]) +{ + struct sqlca sqlca; + EXEC SQL CONTEXT USE DEFAULT; + EXEC SQL ENABLE THREADS; + + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->load("config.server"); + + const string connectInfo = initData.properties + ->getPropertyWithDefault("Oracle.ConnectInfo", "scott/tiger"); + CurrentSqlContext currentCtx(connectInfo); + initData.threadHook = currentCtx.getHook(); + + HRServer app(currentCtx); + return app.main(argc, argv, initData); +} + +HRServer::HRServer(const CurrentSqlContext& currentCtx) : + _currentCtx(currentCtx) +{ +} + +int +HRServer::run(int argc, char* argv[]) +{ + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("HR"); + + const string empCategory = "Emp"; + const string deptCategory = "Dept"; + + adapter->addServantLocator(new DefaultServantLocator( + new EmpI(_currentCtx, empCategory, deptCategory)), + empCategory); + + adapter->addServantLocator(new DefaultServantLocator( + new DeptI(_currentCtx, empCategory)), + deptCategory); + + adapter->add(new DeptFactoryI(_currentCtx, deptCategory), + communicator()->stringToIdentity("DeptFactory")); + + adapter->activate(); + communicator()->waitForShutdown(); + return EXIT_SUCCESS; +} + diff --git a/cpp/demo/Database/Oracle/proc/Util.h b/cpp/demo/Database/Oracle/proc/Util.h new file mode 100644 index 00000000000..5966097665e --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/Util.h @@ -0,0 +1,22 @@ +// ********************************************************************** +// +// 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 <string> +#include <sqlca.h> + +void handleSqlError(const struct sqlca&, sql_context); + +int decodeName(const std::string&); + +std::string encodeName(int); + +#endif diff --git a/cpp/demo/Database/Oracle/proc/Util.pc b/cpp/demo/Database/Oracle/proc/Util.pc new file mode 100644 index 00000000000..2c30064995c --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/Util.pc @@ -0,0 +1,59 @@ +// ********************************************************************** +// +// 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <HR.h> +#include <Util.h> +#include <sstream> + +using namespace std; + +void handleSqlError(const struct sqlca& badca, sql_context sc) +{ + // + // First rollback transaction + // + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = sc; + EXEC SQL END DECLARE SECTION; + + struct sqlca sqlca; + EXEC SQL CONTEXT USE :ctx; + EXEC SQL ROLLBACK; + + if(badca.sqlcode > 0) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + else + { + string msg(badca.sqlerrm.sqlerrmc, badca.sqlerrm.sqlerrml); + throw HR::SqlException(msg); + } +} + +int decodeName(const string& name) +{ + int result = 0; + istringstream is(name); + is >> result; + if(!is || !is.eof()) + { + cerr << "Unable to decode " << name << endl; + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + return result; +} + +string encodeName(int n) +{ + ostringstream os; + os << n; + return os.str(); +} diff --git a/cpp/demo/Database/Oracle/proc/config.client b/cpp/demo/Database/Oracle/proc/config.client new file mode 100644 index 00000000000..be8c63ec65c --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/config.client @@ -0,0 +1 @@ +HR.DeptFactory=DeptFactory:tcp -p 10000 diff --git a/cpp/demo/Database/Oracle/proc/config.server b/cpp/demo/Database/Oracle/proc/config.server new file mode 100644 index 00000000000..3befc7a5838 --- /dev/null +++ b/cpp/demo/Database/Oracle/proc/config.server @@ -0,0 +1,6 @@ +HR.Endpoints=tcp -p 10000 + +Ice.ThreadPool.Server.Size=5 + +Oracle.ConnectInfo=scott/tiger + |