How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
jesuslpm
Posts: 5
Joined: Wed 13 Dec 2017 11:13

How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Post by jesuslpm » Wed 13 Dec 2017 11:23

Documentation for Direct Mode says:
dotConnect for Oracle supports Oracle Advanced Security data encryption and data integrity in the Direct mode and can connect to Oracle Database as a Service (DBaaS).
However I cannot find more information about the subject.

Could you please explain how to connect to a Database Cloud Service (DBaaS) Instance using dotConnect for Oracle in Direct Mode?

jesuslpm
Posts: 5
Joined: Wed 13 Dec 2017 11:13

Re: How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Post by jesuslpm » Thu 14 Dec 2017 15:12

There is nothing special on connecting to Oracle Database Cloud Service other than establishing an SSH tunel.

Oracle provides some documentation:
Developing .NET Applications for Oracle Database as a Service
Connecting to a Database Cloud Service (DBaaS) Instance Through an SSH Tunnel

However you won't want to call putty o ssh from your .NET application. What you will want is to establish the SSH tunnel by c# code. SSH.NET will help you on that.

Here you have c# .NET Core 2.0 sample code that establish an SSH tunel, connect to a portable database on Oracle Database Cloud Service and execute the hello world query:

Code: Select all

class Program
{
    static void Main(string[] args)
    {
        var port = new ForwardedPortLocal("127.0.0.1", 1521, "localhost", 1521);
        PrivateKeyFile file = new PrivateKeyFile(@"path to the private key file");
        using (var client = new SshClient("the public ip address of your oracle database cloud", "oracle", file))
        {

            client.Connect();
            client.AddForwardedPort(port);
            port.Start();

            var cnstring = "User Id=UserName;Password=UserPassword;Direct=true;Data Source=localhost;Port=1521;Service Name=PDB1.YouCloudIdentityDomain.oraclecloud.internal";
            using (var cn = new Devart.Data.Oracle.OracleConnection(cnstring))
            using (var cmd = new Devart.Data.Oracle.OracleCommand("SELECT 'Hello from Oracle Cloud' FROM DUAL", cn))
            {
                cn.Open();
                Console.WriteLine(cmd.ExecuteScalar());
            }
            client.Disconnect();
        }
    }
}

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Post by Shalex » Fri 15 Dec 2017 12:16

Thank you for the information.

JIC

* Oracle Advanced Security Support in Direct Mode is described at https://www.devart.com/dotconnect/oracl ... tMode.html > the "Oracle Advanced Security Support in Direct Mode" section

* simple use case

Code: Select all

            // settings in Oracle Server's sqlnet.ora file:
            // SQLNET.ENCRYPTION_SERVER= REQUIRED 
            // SQLNET.ENCRYPTION_TYPES_SERVER= (RC4_256)
            // SQLNET.CRYPTO_CHECKSUM_SERVER= REQUIRED
            // SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER= (MD5)

            DirectUtils.EncryptionLevel = DirectUtils.SecurityLevel.Required;
            DirectUtils.DataIntegrityLevel = DirectUtils.SecurityLevel.Required;

            using (var conn = new OracleConnection()) {
                conn.ConnectionString = "direct=true;server=192.168.0.93;sid=orcl;uid=scott;pwd=tiger;";
                conn.Open();
                var cmd = conn.CreateCommand();
                cmd.CommandText = "select 1 + 1 from dual";
                Console.WriteLine(cmd.ExecuteScalar());
            }
            Console.ReadKey();

jesuslpm
Posts: 5
Joined: Wed 13 Dec 2017 11:13

Re: How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Post by jesuslpm » Sat 16 Dec 2017 12:19

Thanks Shalex for your response.

What I don't understand is how Oracle Advanced Security relates to accessing Oracle Database Cloud Service.

I can connect to Oracle Database Cloud service without using Oracle Advanced Security, by establishing an SSH tunel, however the docs says "dotConnect for Oracle supports Oracle Advanced Security data encryption and data integrity in the Direct mode and can connect to Oracle Database as a Service (DBaaS)."

Regards

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Post by Shalex » Thu 21 Dec 2017 10:36

jesuslpm wrote:What I don't understand is how Oracle Advanced Security relates to accessing Oracle Database Cloud Service.
Connection to Oracle Database Cloud Service can be established if Oracle Advanced Security is supported by a provider. Default provider settings:
DirectUtils.EncryptionLevel = DirectUtils.SecurityLevel.Accepted;
DirectUtils.DataIntegrityLevel = DirectUtils.SecurityLevel.Accepted;

jesuslpm
Posts: 5
Joined: Wed 13 Dec 2017 11:13

Re: How to connect to Oracle Database as a Service (DBaaS) in Direct Mode

Post by jesuslpm » Thu 21 Dec 2017 10:50

Got it!
Thank you very much!

Post Reply