Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Link to non-existing page removed

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Activate Java Code in Oracle

1. Java-Source: SOSSchedulerCommand.java

insert before the class definition

Code Block

  create or replace and compile java source named
    SOSSchedulerCommand
  as

and after the last bracket a semicolon ((wink)

...

";"

Put the source code to db using SQL Worksheet or similar.

2. Java-Source: YourSchedulerCommand.java (if you have one)

insert before the class definition

Code Block

  create or replace and compile java source named
    DocumentFactorySchedulerCommand
  as

and after the last bracket a semicolon ";"

Put semicolon((wink)> put the source code to db using SQL Worksheet or similar.

3. Wrapper Procedure: Scheduler_Add_Order.sql

Code Block

   Create a PL/SQL-Prozedur with the following content:
Code Block

   create or replace procedure SCHEDULER_ADD_ORDER(host varchar2, port number, status number, job_chain varchar2)
   as language java
   name 'SOSSchedulerCommand.addOrder(java.lang.String, int, int, int, int, java.lang.String)';

and

Code Block

 create or replace PROCEDURE SCHEDULER_START_JOB(host varchar2, port number, jobName varchar2, jobParams varchar2)
   as language java  name 'SOSSchedulerCommand.startJob(java.lang.String, int, java.lang.String, java.lang.String)';

...

4. Add execution rights for TCP/UDP-connections
a) if using TCP:

Code Block

   call dbms_java.grant_permission( 'FACTORY', 'SYS:java.net.SocketPermission', 'localhost', 'resolve' );
   call dbms_java.grant_permission( 'FACTORY', 'SYS:java.net.SocketPermission', '127.0.0.1:4363', 'connect,resolve' );

b) if using UDP (default):

Code Block

   call dbms_java.grant_permission( 'FACTORY', 'SYS:java.net.SocketPermission', 'localhost:1024-', 'listen,resolve' );
   call dbms_java.grant_permission( 'FACTORY', 'SYS:java.net.SocketPermission', '127.0.0.1:4363', 'accept,resolve' );

A. Testing with SQL Worksheet (or similar):

a) Procedure

Code Block

   /* host, port, letter, status, model, job_queue */
   CALL SCHEDULER_ADD_ORDER( 'localhost', 4363, 4711, 0, 2, 'factory_print' );

b) Debugging

Code Block

   set serveroutput on size 5000
   call dbms_java.set_output(5000);

B. Defining the trigger in Oracle (example)

Code Block

 create or replace TRIGGER "myTrigger" AFTER
 INSERT OR UPDATE ON "Any_Table" FOR EACH ROW
 DECLARE
   jobid               binary_integer;
 BEGIN
 
  IF :new."DOWNLOAD" = 2 THEN
    SCHEDULER_START_JOB('localhost', 4363, 'myJobname', '<params><param name="queue" value="' ||  :new."NORMALIZED_NAME" || '"/><param name="directory" value="download_einzeldrucker"/></params>');
  END IF;
 
 EXCEPTION
   WHEN NO_DATA_FOUND THEN
     BEGIN
       /* Default: raise an error */
       RAISE_APPLICATION_ERROR( -20001,'TRIGGER:LF_QUEUES_SIGNAL: job could not be started: myJobname' );
     END;
   WHEN OTHERS THEN
     BEGIN
       /* Default: raise an error */
       RAISE_APPLICATION_ERROR( -20002, 'TRIGGER:LF_QUEUES_SIGNAL: an error occurred: ' || SQLCODE );
     END;
 
 END;