Last modified: January 09, 2012
Applies to: Windows | Windows Server
The JetTerm2 function initiates the shutdown of an instance that has been initialized by JetInit.
JetTerm2 can also destroy an uninitialized instance that was created by JetCreateInstance.
JET_ERR JET_API JetTerm2( __in JET_INSTANCE instance, __in JET_GRBIT grbit );
The instance to use for this call.
Windows 2000: This parameter is ignored and should always be NULL.
Windows XP and later releases: This parameter is overloaded. If the engine is operating in legacy mode (Windows 2000 compatibility mode) where only one instance is supported, then this parameter might be NULL or might contain the actual instance that is returned by JetInit. If the engine is operating in multi-instance mode, then this parameter must be a pointer to an instance that was created using JetCreateInstance.
A group of bits that contain the options to be used for this call, which include zero or more of the following values.
Requests that the instance be shut down cleanly. Any optional cleanup work that would ordinarily be done in the background at run time is completed immediately.
Requests that the instance be shut down as quickly as possible. Any optional work that would ordinarily be done in the background at run time is abandoned.
Note This option can cause temporary or permanent space loss in the database. This lost space can always be recovered through an offline defragmentation of the database.
Requests that the instance be shut down even if there is currently a backup in progress. Ordinarily, a pending backup would cause JetTerm to fail with JET_errBackupInProgress. When this parameter is not present, its value is presumed to be JET_bitTermAbrupt.
Requests that the instance be shut down with all the attached databases left in a dirty state.
Windows 7: JET_bitTermDirty is introduced in Windows 7.
This function returns the JET_ERR datatype with one of the following return codes. For more information about the possible ESE errors, see Extensible Storage Engine Errors and Error Handling Parameters.
The operation completed successfully.
The operation cannot complete because a backup operation is in progress on the instance.
One of the parameters that was provided contained an unexpected value, or the combination of several parameters yielded an unexpected result. This error will be returned by JetTerm when the engine is in multi-instance mode and when pinstance refers to an invalid instance.
Windows XP: This return value is introduced in Windows XP.
The operation cannot complete because the instance has not yet been initialized.
The operation cannot complete because the instance is being shut down.
It is not possible to complete the operation because a restore operation is in progress on the instance.
The instance cannot be shut down because there are currently sessions with active transactions for the specified instance. This error occurs only if the JET_bitTermComplete is used.
If this function succeeds, the specified instance will be shut down. The instance handle will also be closed and made unavailable to any API that takes an instance handle. All other objects that are associated with the instance, such as sessions, will also be closed. The state of the checkpoint file, transaction log files, and the database files attached to the instance will be modified during the shutdown process.
If this function fails as a result of a usage error, then the instance remains in an initialized state and nothing changes. Otherwise, the instance is still shut down as stated for the success case. The difference is that the instance will need to go through crash recovery when it is next initialized. The engine will try to flush as much data as possible to minimize the amount of recovery that is required. Conceptually, such a failure of JetTerm is no different than a process crash.
Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Declared in Esent.h.