Features at a glance
Java in the database: other examples
|This is Release 1.0! |
There are many cases in which interaction of the Oracle database with the operating system or file system is needed. The database provides some PL/SQL packages for this out-of-the-box (UTL_FILE for File access, DBMS_SCHEDULER for executing a shell command), but there are still tasks which cannot be achieved with those packages. The here provided packages close this gap.
Usage example of OS_COMMAND within Oracle SQL*Plus
NEW FEATURES IN RELEASE 1.0:
Technical backgroundThis package utilizes the JVM which is embedded in the database since Oracle8i. Every JVM provides operating system interaction out-of-the-box:
Java has an own security mechanism: The database user which calls the functions and procedured needs appropriate privileges in order to access files or execute shell commands. These privileges can be granted fine-grained using the DBMS_JAVA.GRANT_PERMISSION procedure. The documentation pages for FILE_TYPE and OS_COMMAND contain some examples. The "traditional" PL/SQL directory objects are not used by the database JVM.
The advantage of the JVM's Java2-based security is a much more fine-grained permission handling than PL/SQL: Permissions might be granted on single files, whole directory trees and furthermore negative permissions (DBMS_JAVA.RESTRICT_PERMISSION) are possible: A user might be granted privileges for a file system folder but not for a special file in it. More information about the security mechanism is contained in the Oracle documentation.