Skip to content

Instantly share code, notes, and snippets.

@krisrice
krisrice / DBToolsServiceRestSQLExamples.java
Last active November 17, 2021 17:33
DBTools Service sample for REST-SQL
package io.krisice;
import com.oracle.bmc.http.signing.RequestSigningFilter;
import javax.ws.rs.client.*;
import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
set scan off
set define off
script sqlid.js
set statusbar add sqlid
set scan off
set define off
script
var StatusBarComponent = Java.type("oracle.dbtools.raptor.console.StatusBarComponent");
var component = new StatusBarComponent() {
getName: function() {
return "cmdstatus";
},
getDescription: function() {
set scan off
set define off
script
var StatusBarComponent = Java.type("oracle.dbtools.raptor.console.StatusBarComponent");
var component = new StatusBarComponent() {
getName: function() {
return "beer";
},
getDescription: function() {
from oraclelinux:8
run yum-config-manager --add-repo=http://yum.oracle.com/repo/OracleLinux/OL8/oracle/software/x86_64
run yum -y install ords
DECLARE
l_roles owa.vc_arr;
l_patterns owa.vc_arr;
l_modules owa.vc_arr;
BEGIN
l_roles(1) := 'SQL Developer';
l_patterns(1):= '/dba/*';
l_modules(1) := 'dba/awr';
var OCIProfiles = Java.type("oracle.dbtools.oci.OCIProfiles");
var OCIRESTClient = Java.type("oracle.dbtools.oci.OCIRESTClient");
var OCIRequest = Java.type("oracle.dbtools.oci.OCIRequest");
var Instant = Java.type("java.time.Instant");
var DateTimeFormatter = Java.type("java.time.format.DateTimeFormatter");
var TemporalAccessor = Java.type("java.time.temporal.TemporalAccessor");
var FileUtils = Java.type("oracle.dbtools.common.utils.FileUtils");
var StandardCopyOption = Java.type("java.nio.file.StandardCopyOption");
var Files = Java.type("java.nio.file.Files");
var Paths = Java.type("java.nio.file.Paths");
script
// issue the sql
var binds = {}
var ret = util.executeReturnList('select help_text,page_name from APEX_APPLICATION_PAGES where rownum=1 and help_text is not null',binds);
// loop the results
for (i = 0; i < ret.length; i++) {
// debug is nice
ctx.write( ret[i].PATH+ "\n");
// get the CLOB stream
#
# Print current instances for autonomous db
# Uses $OCI_TENANCY for compartment id since that is the "root"
#
cat > db.jq <<EOF
.data[] |
."db-name" + "\tocid:" + .id ,
"\t" + ."db-name" + "_low" ,
"\tORDS Version: " + ."apex-details"."ords-version",
"\tAPEX Version: " + ."apex-details"."apex-version",
<html>
<head>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/hack-font@3/build/web/hack-subset.css">
<script>
var refreshInteval;
function poolListing(){
// populate the list of pools
fetch('http://localhost:8080/ords/_/instance-api/stable/database-pools-cache/',