Steps to Set Up and Access Oracle Database with Java
SQL vs. NoSQL
Let's explore the key differences between SQL and NoSQL databases in a concise yet comprehensive way.
Database Basics
Head-To-Head Comparison
SQL
NoSQL
Key Differences
In summary, SQL offers robust support for structured data management, while NoSQL provides the agility needed for modern, scalable, and data-driven applications.
Setting Up Oracle DB
Create a GCP VM:
$ sudo apt update
$ sudo apt install docker.io -y
$ sudo systemctl enable --now docker
Clone the Oracle Docker images repo:
$ git clone https://github.com/oracle/docker-images.git
I will be using OracleDatabase v 18.4.0:
$ cd docker-images/OracleDatabase/SingleInstance/dockerfiles
$ ./buildContainerImage.sh -v 18.4.0 -x
Recommended by LinkedIn
$ docker run --name oraclexe -d -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=ORACLE oracle/database:18.4.0-xe
Connecting to the DB:
Create a new connection with the following credentials:
Username: yourusername
Password:yourpassword
Host: <VM-external-IP>
Port: 1521
SID: XE
Role: defualt
Create the BOOK Table
CREATE TABLE BOOK (
ID NUMBER,
NAME VARCHAR2(128), I
SBN VARCHAR2(32),
CREATE_DATE DATE DEFAULT SYSDATE
);
Write a Java Application to Insert Records
Write a simple Java application to insert 100 random records into the BOOK table.
you can check my code from this Github repository
Verify
From Sql developer review the table
SELECT * FROM BOOK;
Conclusion
Setting up an Oracle Database on a GCP VM using Docker is a modern and efficient approach to quickly deploy and manage a robust RDBMS. With Docker, you eliminate the need for complex installations, as it provides a pre-configured environment for Oracle Database.
This setup is highly portable, scalable, and ideal for development, testing, or even production workloads. By leveraging Docker and GCP, you can take advantage of Oracle’s enterprise-grade features while maintaining flexibility and cost-effectiveness.