petek, 3. februar 2012

PL/SQL in JAVA - vračanje sistemskih parametrov

Pri nekem projektu sem naletel na potrebo po zaznavi operacijskega sistema na katerem teče podatkovna baza Oracle. Pravtako sem potreboval verzijo java prevajalnika saj sem moral uporabiti knjižnice, ki so bile prevedene s točno določenim prevajalnikom (1.5).

Pri tem primeru sem si pomagal s pl/sql funkcijo, ki pokliče statično metodo razreda java.lang.System getPropery.
Z naborom parametrov lahko tako v pl/sql-u pridobimo sledeče vrednosti (glej tabelo)

java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory










Funckija:
create or replace function f_vrni_parameter(p_vhodni in varchar2) return varchar2 as language java name  'java.lang.System.getProperty(java.lang.String) return java.lang.String';


Klic v pl/sql-u pa


select f_vrni_parameter('java.version') from dual
select f_vrni_parameter('os.version) from dual 
 

Nekaj podobnih vrednosti lahko dobimo tudi v paketu DBMS_UTILITY vendar ta ni podprt pri starejših bazah podatkov

2 komentarja:

  1. Hi,
    I saw you post in Oracle (Jdeveloper 11, PLSQL webservice, how to deploy it on glassfish server?) at this link https://community.oracle.com/thread/3564377

    I face same problem and I need this urgently did you solve this problem? I try to get your email but I can not find it in your profile so I write my question here. Thanks

    OdgovoriIzbriši
    Odgovori
    1. Please look at my response on : https://community.oracle.com/thread/3564377

      Izbriši