| Devart.Data.Oracle Namespace : OracleHome Class |
Represents an Oracle home.
For a list of all members of this type, see OracleHome members.
Devart.Data.Oracle.OracleHome
[Visual Basic]
Public NotInheritable Class OracleHome [C#]
public sealed class OracleHome Use the OracleHome properties to retrieve name, version, physical path and language settings (the NLS_LANG variable) for the specifed Oracle home. Use the GetClientInfo method to get the Oracle globalization settings of current Oracle home, such as date format, time zone, currency and language. Use the GetServerList method to see the list of Oracle servers (TNS names) available for the current Oracle home.
OracleHome has no public constructors, it can only be retrieved from the OracleHomeCollection. The complete collection of all available Oracle homes can be get from the static interface of the OracleConnection class. See OracleHomeCollection and the OracleConnection.Homes property of the OracleConnection class.
In this example we retrieve the globalization settings of the "OraClient" Oracle home; after that, we try to connect as Scott to all servers described in the tnsnames.ora file of OraClient.
[C#]
// Get the OracleHome instance corresponding to the "OraClient" Oracle home.
OracleHome home = OracleConnection.Homes["OraClient"];
// Print some globalization settings of the current home.
OracleGlobalization glob = home.GetClientInfo();
Console.WriteLine("The Oracle home is registered for: " + glob.Territory);
Console.WriteLine("Character set is " + glob.ClientCharacterSet);
Console.WriteLine("Time zone is " + glob.TimeZone);
Console.WriteLine("Date format is " + glob.DateFormat);
// Create a connection.
OracleConnection conn = new OracleConnection();
conn.UserId = "Scott";
conn.Password = "tiger";
// Try to connect to each server available for the current Oracle home.
Console.WriteLine("\nTrying to connect as Scott/tiger:\n");
string[] servers = home.GetServerList();
foreach (string serverName in servers)
{
conn.Server = serverName;
try
{
conn.Open();
Console.WriteLine("Successfully connected to " + serverName);
}
catch(Exception ex)
{
Console.WriteLine("Failed connecting to " + serverName + ": " + ex.Message);
}
finally
{
conn.Close();
}
}
Console.ReadLine(); [Visual Basic]
' Get the OracleHome instance corresponding to the "OraClient" Oracle home.
Dim home As OracleHome = OracleConnection.Homes.Item("OraClient")
' Print some globalization settings of the current home.
Dim glob As OracleGlobalization = home.GetClientInfo()
Console.WriteLine("The Oracle home is registered for: " + glob.Territory)
Console.WriteLine("Character set is " + glob.ClientCharacterSet)
Console.WriteLine("Time zone is " + glob.TimeZone)
Console.WriteLine("Date format is " + glob.DateFormat)
' Create a connection.
Dim conn As OracleConnection = New OracleConnection()
conn.UserId = "Scott"
conn.Password = "tiger"
' Try to connect to each server available for the current Oracle home.
Console.WriteLine(vbCrLf + "Trying to connect as Scott/tiger:" + vbCrLf)
Dim servers As Array = home.GetServerList()
For Each serverName In servers
conn.Server = serverName
Try
conn.Open()
Console.WriteLine("Successfully connected to " + serverName)
Catch ex As Exception
Console.WriteLine("Failed connecting to " + serverName + ": " + ex.Message)
Finally
conn.Close()
End Try
Next
Console.ReadLine()OracleHome Members | Devart.Data.Oracle Namespace
© 2002 - 2013 Devart. All Rights Reserved.