The objects of the DSI API have a lifecycle that is modeled on, though not exactly the same as, the lifecycle of ODBC handles. This section explains the lifecycle in the C++ SDK for ODBC drivers.
IDriver object is instantiated when the driver is loaded, and a single instance is alive until the driver is unloaded.
IDriver object creates an
IEnvironment when an application allocates environment handles.
IDriver can create multiple
IEnvironment objects. These are guaranteed to have been destroyed by the time the
IDriver is destroyed.
IConnections, which are guaranteed to have been destroyed by the time the parent
IEnvironment has been destroyed.
IConnections can be created and freed when an application chooses, but are typically long-lived objects, with multiple actions occurring before being destroyed.
IStatements, which are guaranteed to have been destroyed by the time the parent
IConnection has been destroyed.
IStatements can be short- or long-lived objects depending on the application. If the application re-uses statements, then they tend to be long-lived, while if the application does not re-use statements they tend to be short-lived.
IDataEngines, which are guaranteed to have been destroyed by the time the parent
IStatement has been destroyed.
IQueryExecutors, which are guaranteed to have been destroyed by the time the parent
IDataEngine has been destroyed.
IQueryExecutors have a lifespan that matches the lifespan of a prepared and executed, or directly executed, query. A single
IQueryExecutor is used for multiple executions of a prepared query.
Any objects created by an
IQueryExecutor are guaranteed to have been destroyed by the time the parent
IQueryExecutor has been destroyed.
IResults, which are destroyed by the
IQueryExecutors that created them. As stated above,
IResults are guaranteed to have been destroyed before the
IResult objects are accessed through
IResults objects. However, the timing of their creation and destruction is determined by a driver’s implementation. The
DSIResults implementation creates
IResult objects during construction and destroys them during destruction. Note that an
IResult object is not accessible after it has been destroyed by the parent