Tuesday, December 8, 2020

Query to get system property (OS name, OS Architecture, OS Version, Oracle Home) and values of environment variables of database server in PLSQL - java.lang.System.getProperty & java.lang.System.getenv

 





          

  In this post, we have given a PLSQL functions which inturn uses the standard Java function to gather the database tier OS level parameters and environment variable details. 

Custom Functions:

CREATE OR REPLACE FUNCTION get_system_property(prop IN VARCHAR2) RETURN VARCHAR2
AUTHID DEFINER IS
LANGUAGE JAVA
name 'java.lang.System.getProperty(java.lang.String) return java.lang.String';
CREATE OR REPLACE FUNCTION get_env_var_path(prop IN VARCHAR2) RETURN VARCHAR2
AUTHID DEFINER IS
LANGUAGE JAVA
name 'java.lang.System.getenv(java.lang.String) return java.lang.String';

Query: 

SELECT get_system_property('user.dir') AS oracle_home,
       get_system_property('os.name') AS os_name,
       get_system_property('os.arch') AS os_architecture,
       get_system_property('os.version') AS os_version,
       get_system_property('user.name') AS user_name,
       get_system_property('user.home') AS user_home_directory,
       get_system_property('user.dir') AS user_curr_dir,
       get_system_property('java.vm.version') AS jvm_version,
       get_system_property('java.home') AS JAVA_HOME
FROM dual;
SELECT get_env_var_path('ORACLE_HOME') AS "$ORACLE_HOME",
       get_env_var_path('CONTEXT_FILE') AS "$CONTEXT_FILE",
       get_env_var_path('HOSTNAME') AS "$HOSTNAME"
FROM dual;
System Properties (Quick Reference): 

  1. java.version (Java Runtime Environment version)
  2. java.vendor (Java Runtime Environment vendor)
  3. java.vendor.url (Java vendor URL)
  4. java.home (Java installation directory)
  5. java.vm.specification.version (Java Virtual Machine specification version)
  6. java.vm.specification.vendor (Java Virtual Machine specification vendor)
  7. java.vm.specification.name (Java Virtual Machine specification name)
  8. java.vm.version (Java Virtual Machine implementation version)
  9. java.vm.vendor (Java Virtual Machine implementation vendor)
  10. java.vm.name (Java Virtual Machine implementation name)
  11. java.specification.version (Java Runtime Environment specification version)
  12. java.specification.vendor (Java Runtime Environment specification vendor)
  13. java.specification.name (Java Runtime Environment specification name)
  14. java.class.version (Java class format version number)
  15. java.class.path (Java class path)
  16. java.library.path (List of paths to search when loading libraries)
  17. java.io.tmpdir (Default temp file path)
  18. java.compiler (Name of JIT compiler to use)
  19. os.name (Operating system name)
  20. os.arch (Operating system architecture)
  21. os.version (Operating system version)
  22. file.separator (File separator ("/" on UNIX))
  23. path.separator (Path separator (":" on UNIX))
  24. line.separator (Line separator ("\n" on UNIX))
  25. user.name (User's account name)
  26. user.home (User's home directory)
  27. user.dir (User's current working directory)

0 Responses to “Query to get system property (OS name, OS Architecture, OS Version, Oracle Home) and values of environment variables of database server in PLSQL - java.lang.System.getProperty & java.lang.System.getenv”

Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.