PL/SQL calls JAVA to obtain the MAC address of the NIC. It is mainly used to learn how PL/SQL calls JAVA. platform: WINDOWS 1. first, use PL/SQL to create and compile the JAVA source file (JAVA source) until there is no error. note that when calling some external JAVA packages, no error may be reported during compilation until you execute the function. The error message is generally: ORA-29540 [java] create or replace and compile java source named getosmac as import java. io. *; public class GetOSMac {/*** get MAC address */public static String getMac () {String result = ""; try {Process process = runtime.getruntime(cmd.exe c ("ipconfi G/all "); -- Obtain InputStreamReader ir = new InputStreamReader (process. getInputStream (); LineNumberReader input = new LineNumberReader (ir); String line; while (line = input. readLine ())! = Null) if (line. indexOf ("Physical Address")> 0) {String MACAddr = line. substring (line. indexOf ("-")-2); result = MACAddr ;}} catch (java. io. IOException e) {System. err. println ("IOException" + e. getMessage ();} return result;} public static void main (String [] args) {System. out. println ("OK !!! "};}2. then create a function to call the java source [SQL] create or replace function GetMac return varchar2 is language java name 'getosmac. getMac () return java. lang. string '; 3. call a function. [SQL] 11:13:04 SYS @ orcl> select GetMac AS MAC from dual; MAC ---------------------------------------------------- 50-e5-49-17-ec-82 1 row has been selected.