With Oracle Database 19.3 and Node.js 10 now available, this is a great time to create a local sandbox for learning. Thanks to some prebuilt VMs provided by Oracle, you can have such an environment up and running in less than 20 minutes (excluding download times) without spending a dime! 😄
In this post, I’ll walk you through the creation of such a sandbox. Here’s an overview of what we’ll be working through:
- Install VirtualBox
- Import Database App Development VM
- Install Node.js and Git
- Install the Node.js Driver and Run a Test
VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL) version 2.
VirtualBox is a great solution for this type of sandbox because we don’t have to install any software on our host operating system which would consume resources when not in use. I will not cover the installation process in any detail as it will vary depending on your host OS. Just navigate to the downloads page and download & install the appropriate binaries for your OS.
Import the Database App Development VM
Oracle provides a number of pre-built development VMs that are great for learning Oracle technology as you don’t have to muddle through complicated installs to get going. Navigate to the Database App Development VM page where you’ll see a list of the included software.
Check out all the goodies in that VM! Note that Oracle Database 19.3 includes the latest enhancements for working with JSON data. See the Database JSON Developer’s Guide for details and give them a go once the VM is up and running.
Click the “Oracle DB Developer VM” link in Step 2 to being the download.
If you’ve not already authenticated with your Oracle account, you’ll be redirected to a page to do so before the download begins. If you don’t have an account just click the Create Account button on that page to create your free account.
Once the download completes you’ll be ready to import the VM into VirtualBox. Open VirtualBox and click File > Import Appliance. Use the appliance import wizard to select the DeveloperDaysVM2019-05-31_20.ova file you downloaded and click Import.
The import process will begin once you accept the license agreement. Once complete, click on the new VM in the menu on the left, then click the run button.
A new window will open up with the VM running a terminal inside (you can resize the VM window as needed).
Here are a few tips to get you started inside the VM:
- The password for everything is: oracle
- Double-click the large START icon on the desktop to open a browser with labs on a variety of Oracle technology.
- To access APEX, navigate the browser to http://localhost:8080/apex. Log in using OBE for the workspace and username fields and oracle for the password.
- To be able to copy/paste things between the host and guest OS, go to the VirtualBox menu bar and select Devices > Shared Clipboard > Bidirectional. Trust me, this will come in handy!
With the VM up and running we’re ready to install Node.js and Git.
Install Node.js and Git
In this section, we’ll install Node.js and Git. Git will be used to install the Node.js driver for Oracle Database in the next step.
Open a terminal and switch to the root user:
su - root
# password is oracle
Run the following commands as the root user:
yum group install "Development Tools" -y
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
yum install nodejs -y
That’s all there is to it, Node.js and Git are ready to go. On to the driver!
Install the Node.js Driver and Run a Test
Example scripts for the driver can be found at: https://github.com/oracle/node-oracledb/tree/master/examples. The easiest way to start running the examples is to use Git to clone the driver repo from GitHub. From there we can copy the examples into our own directory, change the password in dbconfig.js, install the driver, and start testing!
Now run the following commands:
git clone https://github.com/oracle/node-oracledb.git
mkdir -p projects/oracledb-examples
cp ~/node-oracledb/examples/* .
sed -i -e 's/process\.env\.NODE_ORACLEDB_PASSWORD/"oracle"/' dbconfig.js
sed -i -e 's/orclpdb1/orcl/' dbconfig.js
npm init -y
npm install oracledb --save
Running other examples only requires node followed by the name of the example you’d like to run:
Enjoy your new sandbox!