SQL Developer provides an easy way to connect Oracle Database. Just start, enter database information like Host, Service, port, and click on connect.
But, how to connect to the cloud database?
Ports ranging from 1520-1530 are not available on secure Oracle public cloud. You need to connect the oracle database using a secure shell (SSH) and port forwarding on secure port 22.
1. Create New SSH Host in SQL Developer
Open SQL Developer and click on View -> SSH toolbar. This brings ssh window as shown below.
Select SSH Hosts and right-click to create New SSH Host…
Enter details as shown in the below image and click OK. You need to use the open ssh key generated while instance setup and add a local port forward.
- Name: Any valid name
- Host: IP of Oracle Cloud Instance
- Username: enter OPC
- Use key file: Browse and select ssh key
- Check Add a Local Port Forward
- Name: Specify proper name
- Host: IP of Oracle Cloud Instance
Click OK.
This creates a new SSH host.
2. Test SSH connection
SSH setup is complete and now let’s connect and test it before connecting to the database. Navigate to SSH Hosts window. Select newly created connection, right-click and you can either click on Test or Connect.
If your key is secured by Passphrase, enter that key and click on connect.
3. Connect to Database
Navigate to the Connections window, select Connections, right-click and click on a new connection.
Enter the connection name, username, and password. Choose the connection type as SSH as we are not using TCP/IP here. Choose Port Forward as recently created SSH connection and service name (Oracle Database Service Name). Click the Save button to save all details so that you do not have to enter those again. Click the connect button.
Open a SQL sheet and run any query to see the results.
Let me know if you find this article useful in the comments section below. Do let me know if you need any help to set up it.
Summary
Thanks to secure shell (SSH) and port forwarding feature in SQL Developer using which you can easily connect Oracle Cloud database.