Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Wednesday, May 29, 2019

Working with an Oracle database using Ballerina

Ballerina version used: 0.992.0
Oracle database version used: Oracle-xe-11g (Follow these instructions explained here to install Oracle-xe-11g with Docker).


This Sample is written using ballerinax/jdbc module. Before running this sample you need to copy the Oracle JDBC driver jar into $BALLERINA_HOME/bre/lib.

First, create the table using the following command:

This is a sample to insert byte array into oracle database:

Running the sample:

ballerina run insertByteArray.bal

Output:

Update oracledb table status: 1

Installing Oracle XE 11g on Ubuntu

Installing Oracle XE with Docker


Docker is an application container for Linux. It is based on LXC and gives you the ability to package complete application including their dependencies to a self-containing file called an image. These images can be exchanged and run on every Linux machine where Docker is installed.  It is the easiest way to install Oracle XE. Docker images are also shared around the community on https://index.docker.io.

  1. First, you need to install Docker on Ubuntu. Follow the instructions given in this doc.

  2. Pull the image to your machine using the following command :

  3. docker pull arahman/docker-oracle-xe-11g
    

  4. Run the image using the following command :

  5. docker run -d -p 49160:22 -p 49161:1521 -p 49162:8080 arahman/docker-oracle-xe-11g /sbin/my_init
    

  6. Connect to the database with the following setting:

  7. hostname: localhost
    port: 49161
    sid: xe
    username: system
    password: oracle
    

  8. You can connect to the database using SQL*Plus