Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

JDBC and JSON in Oracle Database

This directory contains examples of how to store and access JSON type values in Oracle Database from a Java program.

See also:

Running the examples

Create a database

These examples must be run against Oracle Database 23c or later. You can either run the database yourself:
https://www.oracle.com/database/free/get-started/

Or, you can use an always-free Autonomous Database in the cloud:
https://github.com/oracle/json-in-db/blob/master/JdbcExamples/adbs/README.md

Setup the examples

  1. Clone these examples from github. For example:

    git clone https://github.com/oracle/json-in-db.git
    cd json-in-db/JdbcExamples/
    

    If you don't have git you can alternatively download them here: https://github.com/oracle/json-in-db/archive/master.zip

  2. Install Java and Maven

  3. Build the examples:

    mvn package
    

Run the examples

If you are running Oracle Database 23ai Free yourself, then the connection string will look like this:

jdbc:oracle:thin:user/password@//localhost:1521/freepdb1

If you are using the Autonomous Database, the connection string will look something like this:

jdbc:oracle:thin:admin/mypass@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=k1sf7opduakoqs_jsondemo_low.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))

See adbs/README.md for instructions on obatining the connection string for your database.

  1. Run all the examples:

     mvn -q exec:java \
      -Dexec.mainClass="movie.RunAll" \
      -Dexec.args='<connection string>'
    
  2. Drop the table used by the examples:

     mvn -q exec:java \
      -Dexec.mainClass="movie.DropTable" \
      -Dexec.args='<connection string>'
    
    
  3. You can also run specific examples, one at a time:

     mvn -q exec:java \
      -Dexec.mainClass="movie.CreateTable" \
      -Dexec.args='<connection string>'