dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleDatabase Class
Members Example

OracleDatabase Class
This class represents an Oracle Database instance and allows you to start and stop it.
Syntax
'Declaration
 
Public Class OracleDatabase 
   Implements System.IDisposable 
 
Remarks

Note that if you connect to an Oracle 12c (or later) container (root) database - CDB, you can shutdown it with the OracleDatabase class, however after this OracleDatabase class cannot start it again. You need to have either physical or remote access to the server to start it, for example, by restarting the Oracle instance. So, it's not recommended to use the OracleDatabase class with a CDB

This class is not supported in the OracleConnection.Direct mode.

This class is available only in Professional and Developer Editions. It is not available in Standard and Mobile Editions.

Example
This sample creates and opens an OracleConnection instance, and if the target Oracle Database exists but is stopped, the sample attempts to start it.
private OracleConnection OpenConnection() {

        string connectionString = "Data Source=ora; User Id=sys; Password=manager; Connect Mode=sysdba;";

        try {
                OracleConnection connection = new OracleConnection(connectionString);
                connection.Open();
                return connection;
        }
        catch (OracleException ex) {
                if (ex.Code == 1034) { // ORA-01034: ORACLE not available            
                        using (OracleDatabase database = new OracleDatabase(connectionString)) {
                                database.Startup();
                        }
                        OracleConnection connection = new OracleConnection(connectionString);
                        connection.Open();
                        return connection;
                }
                else
                        throw;
        }
}
Private Function OpenConnection() As OracleConnection

        Dim connectionString As String = "Data Source=ora; User Id=sys; Password=manager; Connect Mode=sysdba;"

        Try
                Dim connection As New OracleConnection(connectionString)
                connection.Open()
                Return connection
        Catch ex As OracleException
                If ex.Code = 1034 Then
                        ' ORA-01034: ORACLE not available            
                        Using database As New OracleDatabase(connectionString)
                                database.Startup()
                        End Using
                        Dim connection As New OracleConnection(connectionString)
                        connection.Open()
                        Return connection
                Else
                        Throw
                End If
        End Try
End Function
Inheritance Hierarchy

System.Object
   Devart.Data.Oracle.OracleDatabase

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also