Niels Jespersen
Niels Jespersen

Reputation: 450

How to add configuration options to ODP.Net Managed Driver in Powershell

Using Oracle Managed Data Provider ODP.NET from Powershell works great. However, how to add application specific configuration settings is not quite clear.

How can this be done?

Upvotes: 0

Views: 1367

Answers (1)

Niels Jespersen
Niels Jespersen

Reputation: 450

The configuration settings can be specified in a app.config-file in the normal way. You just need to refer to the config from the powershell script:

$configPath = "\\server1\share1\app_folder\app.config"
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configPath)

Add-Type -Path "C:\Oracle\ODP.NET\managed\common\Oracle.ManagedDataAccess.dll"

$con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User Id=/;Data Source=db")
$con.open()
$con.close()

The config-file can then contain any setting supported by the provider. This includes the possibility of referring to a Oracle Wallet, so that no passwords need be specified in the script.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <oracle.manageddataaccess.client>
    <version number="4.121.2.0">
      <settings>
        <setting name="WALLET_LOCATION" value="(SOURCE = (METHOD = FILE)(METHOD_DATA =(DIRECTORY = \\server1\share1\app_folder\wallet)))"/>
        <setting name="SQLNET.WALLET_OVERRIDE" value="true"/>
      </settings>
    </version>
  </oracle.manageddataaccess.client>
</configuration>

Upvotes: 1

Related Questions