Connect to a Database by Using SQLNet

This section describes how to connect to a database service from a computer that has a SQL*Net client installed. Port 1521 must be open to support the SQL*Net protocol.

Connect From Within the VCN

For security reasons, Oracle recommends that you connect to your database services from within the VCN. You can use this method whether you are connecting to an administration service or to an application service.

To connect using SQL*Plus, you run the following command using the applicable connection string:

sqlplus system/<password>@<connection_string>

Consider the following:

  • If your system is not using the VCN Resolver, ensure that the DB system's hostname (for single-node systems) or SCAN name (for multi-node systems) can be resolved. For information about DNS name resolution, see DNS in Your Virtual Cloud Network.
  • For connecting to the administration service of a PDB, ensure that the PDB is open or the service will not be available.
  • For connecting to an application service, ensure that the service is started. For Fast Application Notification to work, ensure that port 6200 can be reached. For information about Fast Application Notification, see Client Failover Best Practices for Highly Available Oracle Databases.

Connect From the Internet

Although Oracle does not recommend connecting to your database from the Internet, you can connect to a database service by using a public IP address if port 1521 is open to the public for ingress.

To use this method, you run the following command using the public IP address instead of the hostname or SCAN in the connection string:

sqlplus system/<password>@<public_IP>:1521/<service_name>.<DB_domain>

Consider the following:

  • SCANs and hostnames are not resolvable on the Internet, therefore load balancing and failover for multi-node DB systems, which rely on these names, cannot work.
  • For multi-node DB systems, which normally use SCANs, you must specify the IP address of one of the RAC hosts to access the database.

Note:

Do not use this method to connect to the database from within the VCN. Doing so negatively impacts performance because traffic to the database is routed out of the VCN and back in through the public IP address.

Example: Connecting in SQL Developer Using SQL*Net

Prerequisites:

  • Ensure that port 1521 is open for the Oracle default listener. (You can do this by checking the DB system's security list.)
  • If port 1521 is open only to hosts in the VCN, then you must run your SQL Developer client from a machine that has direct access to the VCN. If you are connecting to the database from the Internet instead, then the public IP address of your computer must be granted access to port 1521 in the security list. (Alternatively, the security list can grant full access to port 1521, however, this is not recommended for security reasons.) You must use the public IP address of the host because connecting from the Internet does not support SCAN name resolution.

Connect From Within the VCN Using a Private IP Address

After the prerequisites are met, start SQL Developer and create a connection by supplying the following connection details:

  • Username: sys as sysdba
  • Password: The Database Admin Password that was specified in the Launch DB System dialog in the Console.
  • Hostname: The hostname as it appears in the Easy Connect format of the connection string.For help with getting the connection string and identifying the hostname, see Overview of Connecting to a DB System.
  • Port: 1521
  • Service name: The concatenated name of the service and host domain name, for example, db1_phx1tv.example.com. You can identify this value as the last part of the Easy Connect string, <service_name>.<DB_domain>.