Connecting to Oracle Virtual Box Prebuilt VM’s from the host machine

Oracle Developer Pre-Built VM’s are a superb resource for test driving a database feature or for working through tutorials. I have been using these Virtual Machines (VM) for a number of years but until a colleague was recently demonstrating a proof of concept I wasn’t aware of the that it is possible to connect to the VM from the host machine.

In this post I will demonstrate how to connect to the database running within the Virtual Machine with SQL Developer and Apex which are both on the host machine along with why you might want to do this.

Connecting via SQL Developer

On the host machine download and run SQL Developer. Start the Pre-Built Oracle VM. (The order of the preceding steps is not important).

Create a new SQL Developer connection, the example shows a connection for the HR user.

With the connection set up, you can now interact with the database running on the VM from the host machine.

Connecting via Apex

Once the VM has been started, paste the following URL into a browser running on the host machine:

http://localhost:8080/ 

which will take you to the Apex login page

How?

If you are interested in how this works, Jeff Smith’s post explains it succinctly:

We’ve made it extremely easy. Unless you already have Oracle Database installed and listening to port 1521 on your computer, all of your database connections can simply talk to 127.0.0.1:1521 or localhost:1521. 

That’s because on the VirtualBox Linux appliance, we’ve setup a local port forwarding rule – anything you say to port 1521 on YOUR machine, will go to port 1521 on the Linux VM. And port 1521 is where the database is ‘listening’ for database connections. 

The Easy way to get started with Oracle Database

Why?

A problem I have encountered when using the Pre-Built VM’s is, despite allocating it generous resources, the “flow disturbing” lag when using SQL Developer or Apex from within the VM. Switching to running these from the host machine has eliminated the lag.

Acknowledgements

Thanks to Jeff Smith’s superb post The Easy way to get started with Oracle Database

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.