Deploying .NET Application for Oracle Autonomous Database

Somanathan Gohulan
4 min readApr 25, 2020

--

Hello Everyone, in these days I am working with some multiple projects on developing applications for Oracle Cloud database so thought to make a content on how to deploy the .NET applications for Oracle Autonomous Database, when we consider about the Oracle Cloud Infrastructure there are so many resources ready to deliver services like Azure platform, I have chosen Autonomous Transaction Processing Database as workload type for my development purposes.

The unique is same in developing when we compare with Oracle on premises application development, but some alternative things needs to be done before the deployment.

Will start working with Deploying my application in C# .NET now, for my development I planned to use our traditional Oracle Managed Data Access library from NuGETpackages.

Visual Studio (Solution Explorer >> Reference >> Manager NuGET Packages)

Once it’s downloaded to our Program, just call the reference using statement

using Oracle.ManagedDataAccess.Client;

As the usual manner define the connection string for the Oracle Cloud DB,

OracleConnection conn = new OracleConnection();
conn.ConnectionString = “User ID=ADMIN; Password=Demo@123; Data Source=demooradb_high”;
conn.Open();

So in the connection string I have highlighted the Data Source, so where it’s came from, normally we can find the source name in the TNSNAMES.ORA file on premise database instance. Here to we are going to use the same procedure but to getting know about source name we have to download the tns and other files from the ATP service console. In the ATP service console there are some set of files available for download which are the files going to serve our applications to connect ATP outside from the cloud. These are the files are creating the secure connections in between our applications and ATP in the cloud. These file set can be downloaded as a ZIP file from the console.

ATP Cloud ( DB Connection >> Download Mobile Wallet (Instant Type) >> Download Client Credentials

In the downloaded ZIP file, you can see TNSNAMES.ORA file, open the file in the text editor. In the cloud there are five predefined service names available to connect with database. High,Law,Medium,TPUrgent and TP depends on your processing and workload type you can use any of these service names.

In my workspace my db name is demooradb and using the high service name to connect with ATP

Also in the Autonomous instances, we are only using the ADMIN credentials not the sysdba or system users.

In the same extract or unzip the wallet files to the location where your program is debugging from, here my debug location is (…\ATPDEMO\ATPDEMO\bin\Debug)

Extracted all the files in the location, actually for the .NET we do not want to copy some other files but for the time being I just copied all the files.

Wallet location or directory must be the same location where the program is running from , I changed the location as current root. (./)

Save the sqlnet file and close the editor.

Now the coding part,

using Oracle Command and Oracle Command Reader send the query and get the results to our .NET application.

OracleCommand oraCmd = new OracleCommand(“your query here”, conn);
OracleDataReader oraReader;
oraReader = oraCmd.ExecuteReader();

Finally get the results or display the results in your Windows form application, I am getting my results and displaying in Messagebox in my application.

while (oraReader.Read())
{

MessageBox.Show(oraReader.GetString(0));
}

Close the connections of orareader & Oracle connections.

oraReader.Close();
conn.Close();

Debug the program and Have Fun with Coding !!!

For Detailed coding refer this video tutorial -https://www.youtube.com/watch?v=gUxGyoSrg4g

--

--

Somanathan Gohulan
Somanathan Gohulan

Written by Somanathan Gohulan

Happiest person,Too much of Interest in Technology, Programmer, Positive attitude n all walks of life

No responses yet