Java, SpringBoot, React, Angular, Oracle, PL/SQL, Ellucian Banner, Puppet, Docker, Terraform technical notes
Wednesday, November 29, 2017
PrimeFaces JSF document: 'p:commandButton'
https://www.primefaces.org/docs/vdl/5.1/core/primefaces-p/commandButton.html
https://www.primefaces.org/showcase/ui/button/commandButton.xhtml
ORA-27369: job of type EXECUTABLE failed with exit code: Operation not permitted
chown root $ORACLE_HOME/bin/extjob
chmod 4750 $ORACLE_HOME/bin/extjob
chown root $ORACLE_HOME/rdbms/admin/externaljob.ora
chmod 640 $ORACLE_HOME/rdbms/admin/externaljob.ora
chown root $ORACLE_HOME/bin/jssu
chmod 4750 $ORACLE_HOME/bin/jssu
vi $ORACLE_HOME/rdbms/admin/externaljob.ora
run_user = oracle
run_group = oinstall
chmod 4750 $ORACLE_HOME/bin/extjob
chown root $ORACLE_HOME/rdbms/admin/externaljob.ora
chmod 640 $ORACLE_HOME/rdbms/admin/externaljob.ora
chown root $ORACLE_HOME/bin/jssu
chmod 4750 $ORACLE_HOME/bin/jssu
vi $ORACLE_HOME/rdbms/admin/externaljob.ora
run_user = oracle
run_group = oinstall
PL/SQL Explicit Cursor LOOP
-- PL/SQL Explicit Cursor LOOP
PROCEDURE GET_FILE_LIST
AS
CURSOR c_files IS
Select FILE_NAME, FILE_TYPE, MODIFIED_DATE from FILES_LIST;
Begin
OPEN c_files ;
LOOP
FETCH c_files INTO rec;
EXIT WHEN c_files %NOTFOUND;
dbms_output.put_line(rec.file_name || rec.file_type || rec.modified_date);
END LOOP;
CLOSE c_envelop;
END;
/
PL/SQL Implicit Cursor LOOP
-- PL/SQL Implicit Cursor LOOP
PROCEDURE GET_FILE_LIST
AS
CURSOR c_files IS
Select FILE_NAME, FILE_TYPE, MODIFIED_DATE from FILES_LIST;
Begin
FOR rec in c_files
LOOP
-- your logic code
- rec.file_name
END LOOP;
END;
/
PROCEDURE GET_FILE_LIST
AS
CURSOR c_files IS
Select FILE_NAME, FILE_TYPE, MODIFIED_DATE from FILES_LIST;
Begin
FOR rec in c_files
LOOP
-- your logic code
- rec.file_name
dbms_output.put_line(rec.file_name || rec.file_type || rec.modified_date);
END LOOP;
END;
/
Monday, November 27, 2017
PL/SQL use Java to call shell script
1. Load Java code to PLSQL
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
pr.waitFor();
new Thread(new Runnable(){
public void run() {
BufferedReader br_in = null;
try {
br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
}
br_in.close();
}
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
}
finally {
try {
br_in.close();
} catch (Exception ex) {}
}
}
}).start();
new Thread(new Runnable(){
public void run() {
BufferedReader br_err = null;
try {
br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
}
br_err.close();
}
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
}
finally {
try {
br_err.close();
} catch (Exception ex) {}
}
}
}).start();
}
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
}
}
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
}
};
/
2. Create store procedure to call Java
create or replace PROCEDURE host_command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
3. Run
SET SERVEROUTPUT ON SIZE 1000000
CALL DBMS_JAVA.SET_OUTPUT(1000000);
begin
host_command (p_command => '/home/oracle/xxx.sh');
end;
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
pr.waitFor();
new Thread(new Runnable(){
public void run() {
BufferedReader br_in = null;
try {
br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
}
br_in.close();
}
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
}
finally {
try {
br_in.close();
} catch (Exception ex) {}
}
}
}).start();
new Thread(new Runnable(){
public void run() {
BufferedReader br_err = null;
try {
br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
}
br_err.close();
}
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
}
finally {
try {
br_err.close();
} catch (Exception ex) {}
}
}
}).start();
}
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
}
}
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
}
};
/
2. Create store procedure to call Java
create or replace PROCEDURE host_command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
3. Run
SET SERVEROUTPUT ON SIZE 1000000
CALL DBMS_JAVA.SET_OUTPUT(1000000);
begin
host_command (p_command => '/home/oracle/xxx.sh');
end;
PL/SQL calls Java host command
SET SERVEROUTPUT ON SIZE 1000000
CALL DBMS_JAVA.SET_OUTPUT(1000000);
begin
host_command (p_command => '/home/oracle/xxx.sh');
end;
CALL DBMS_JAVA.SET_OUTPUT(1000000);
begin
host_command (p_command => '/home/oracle/xxx.sh');
end;
Subscribe to:
Posts (Atom)
AWS how to delete VPC when it has error with Network interface , Gateway decencies
how to delete VPC when it has error with Network interface , Gateway decencies in AWS 1. Check if it is running on EC2 instance then Sto...
-
ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1525 ORA-29261: bad argument ORA-29273: HTTP request failed ...
-
Banner 9 Admin: Invalid Object Name fix do steps: A record in GUBOBJS with a UI Version of D. • Records in GURAOBJ to define the defau...
-
chown root $ORACLE_HOME/bin/extjob chmod 4750 $ORACLE_HOME/bin/extjob chown root $ORACLE_HOME/rdbms/admin/externaljob.ora chmod 640 $ORA...