2.1.2 Using the ore.connect and ore.disconnect Functions

The examples in this section demonstrate the various ways of specifying an Oracle R Enterprise connection to an Oracle Database instance.

The examples use sample values for the ore.connect argument values. Replace the sample values with the appropriate values for connecting to your database.

Example 2-1 Using ore.connect and Specifying a SID

This example invokes the ore.connect function and specifies the user, sid, host, password, and port arguments.

ore.connect(user = "rquser", sid = "sales", host = "sales-server",
            password = "rquserStrongPassword", port = 1521 )

Example 2-2 Using ore.connect and Specifying a Service Name

This example demonstrates using a service name rather than a SID. It also specifies connecting to the local host.

ore.connect(user = "rquser", host = "localhost", 
            password = "rquserStrongPassword",
            service_name = "sales.example.com")

Example 2-3 Using ore.connect and Specifying an Easy Connect String

This example uses the conn_string argument to specify an easy connect string that identifies the connection.

ore.connect(user = "rquser", password = "rquserStrongPassword", 
            conn_string = "sales-server:1521:sales
              (ADDRESS=(PROTOCOL=tcp) (HOST=sales-server) (PORT=1521))
              (CONNECT_DATA=(SERVICE_NAME=sales.example.com)))")

Example 2-4 Using ore.connect and Specifying a Full Connection String

This example uses the conn_string argument to specify a full connection string that identifies the connection.

ore.connect(user = "rquser", password = "rquserStrongPassword", 
            conn_string = "DESCRIPTION=
              (ADDRESS=(PROTOCOL=tcp) (HOST=sales-server) (PORT=1521))
              (CONNECT_DATA=(SERVICE_NAME=myserver.example.com))")

Example 2-5 Using the conn_string Argument to Specify an Oracle Wallet

This example uses the conn_string argument to specify an Oracle wallet. The mydb_test string is the connection identifier for the Oracle database. The Oracle wallet contains the information needed to create the connection. For information on creating an Oracle wallet for an Oracle R Enterprise connection, see Oracle R Enterprise Installation and Administration Guide.

ore.connect(conn_string = "mydb_test")

Example 2-6 Using the conn_string Argument and Specifying an Empty Connection String

This example uses an empty connection string to connect to the local host.

ore.connect(user = "rquser", password = "rquserStrongPassword", conn_string = "")

Example 2-7 Using the conn_string Argument in Connecting to a Pluggable Database

This example connects to a pluggable database using the conn_string argument to specify a service name.

ore.connect(conn_string = "pdb1.example.com")

Example 2-8 Using the service_name Argument in Connecting to a Pluggable Database

This example invokes ore.connect using a service name, host name, and port number to connect to a pluggable database.

ore.connect(service_name = "pdb1.example.com", host = "mypdb", port = 1521)

Example 2-9 Disconnecting an Oracle R Enterprise Session

This example explicitly disconnects an Oracle R Enterprise session from an Oracle database.

ore.disconnect()