Accessing the OO4O Automation Server

To access interfaces provided by a COM Automation Server Component and connect to the Oracle server, an instance of the component needs to be created first. In Visual Basic (VB), this is done by calling the CreateObject function. The argument to this function is the Id of the component to be used.

CreateObject returns an interface from which other interfaces may be obtained from the component.
OraSession and OraServer are two interfaces in OO4O that may be returned by calling the CreateObject method.

The script below demonstrates how the OraSession interface is obtained in VB.

Set OO4OSession = CreateObject(OracleInProcServer.XOraSession")

The following example demonstrates how the OraSession interface is obtained in IIS Active Server Pages.

<OBJECT RUNAT=Server SCOPE=APPLICATION ID=OO4OSession PROGID="OracleInProcServer.XOraSession">

</OBJECT>

OracleInProcServer.XOraSession is the version independent program Id for OO4O that is registered in the Windows registry by the Oracle client installation program. It is the symbolic name for a globally unique identifier (CLSID) that identifies the OO4O component. OO4OSession is the variable that holds an instance of the OraSession interface in the previous examples.

After an OraSession interface is obtained, it can be then used to establish a user session in an Oracle database by invoking the
OpenDatabase method.

The following statement connects to the "HRDB" database using "scott/tiger" for the username and password. EmpDb here is a variable that holds an OraDatabase interface and can be used to send commands to the Oracle database for which it holds a network connection and a user session context.

Set EmpDb= OO4ODBSession.OpenDatabase("HRDB", "Scott/Tiger", 0)

HRDB is the network alias that identifies the instance of an Oracle database to connect to.

You can also use the OraServer interface for accessing the OO4O Automation Server and establishing user sessions in an Oracle database. In the following example, a reference to the OraServer interface is obtained and two user sessions, EmpDbSession1 and EmpDbSession2, to the "HRDB" database is established.

Set OO4OServer = CreateObject("OracleInProcServer.XOraServer")

OO4OServer.Open("HRDB")

Set EmpDbSession1 = OO4OServer.OpenDatabase("Scott/Tiger")

Set EmpDbSession2 = OO4OServer.OpenDatabase("Scott/Tiger")

The OraServer interface allows multiple user sessions to share a physical network connection to the database server. This reduces resource usage on the network and the database server, and allows for better server scalability. However, since execution of commands by multiple user sessions are serialized on the connection, this facility is not recommended for use in multi-threaded applications in which parallel command execution is needed for performance.

You can also obtain user sessions from a previously created pool of objects. For a discussion on how to use this feature, see
Using the Connection Pool Management Facility.