Skip to content

Latest commit

 

History

History
98 lines (64 loc) · 2.65 KB

File metadata and controls

98 lines (64 loc) · 2.65 KB

Connecting JavaScript and Oracle Database with ADBC

Instructions

Tip

If you already have an Oracle Database instance running, skip the steps to set up and clean up Oracle Database.

Prerequisites

  1. Install Node.js (version 22 or later)

    • Alternatively, you can use Bun or Deno
  2. Install dbc

Set up Oracle Database

  1. Install Docker

  2. Start an Oracle Database instance:

    docker run -d --rm --name oracle-db -p 1521:1521 -e ORACLE_PWD=password container-registry.oracle.com/database/free:latest
  3. Wait about a minute for the database to initialize.

Connect to Oracle Database

  1. The ADBC driver for Oracle is available from Columnar's private driver registry. Create a Columnar Console account and activate a 14-day free trial. Then authenticate to the registry:

    dbc auth login
  2. Install the ADBC driver for Oracle:

    dbc install oracle
  3. Install the Oracle Instant Client libraries.

  4. Set LD_LIBRARY_PATH (Linux), DYLD_LIBRARY_PATH (macOS), or PATH (Windows) to make sure the Oracle Instant Client libraries are discoverable by your application.

  5. Install dependencies:

    npm --prefix .. install
  6. Customize the script main.js as needed:

    • Change the connection arguments in databaseOptions
      • Format uri according to the following syntax: oracle://[user[:password]@]host[:port][/serviceName][?param1=value1&param2=value2], or keep it as is
    • Change the SQL SELECT statement in conn.query(), or keep it as is
  7. Run the script:

    Node.js:

    node main.js

    Bun:

    bun run main.js

    Deno:

    deno run --allow-ffi --allow-env main.js

Clean up

Stop the Docker container running Oracle Database:

docker stop oracle-db