Getting Control of the Oracle Java Virtual Machine - Page 7

April 29, 2003

Java Backup

A good backup is always a DBA's best friend, especially when the database has a large number of Java Classes, Java Resources, Java Grants and Policies. No special tool is provided by Oracle to handle the Java objects backup, you'll need to use standard utilities.

A Java Classes Backup is made by a full database export without rows.

Example of a full database export:

% exp userid=system full=y ROWS=N file=full_export_norows.dmp 

To restore Java Classes from previously taken backup:

 
% imp userid=system INGORE=Y full=y

Java Privileges Backup is simply a Java grants and policies extraction from the database. Here is the script to extract the Java information (Oracle Metalink, DocID: 183825):

spool setjvmprivs.sql 
set echo off 
set feedback off 
set heading off 
set linesize 80 
set pagesize 1000 
column stmt format a70 word_wrapped 
select 'exec '||stmt 
from (select seq, 'dbms_java.grant_permission('''||grantee||''','''|| 
             type_schema||':'||type_name||''','''||name||''','''||action|| 
             ''');' stmt 
      from dba_java_policy 
      where grantee not in ('JAVADEBUGPRIV', 'JAVASYSPRIV', 'JAVAUSERPRIV', 
                         'JAVA_ADMIN', 'JAVA_DEPLOY', 'SYS', 'PUBLIC') and 
            type_name!='oracle.aurora.rdbms.security.PolicyTablePermission' 
      union all 
      select seq,'dbms_java.grant_policy_permission('''||a.grantee||''','''|| 
             u.name||''','''||permition||''','''||action||''');' stmt 
      from sys.user$ u, 
           (select seq, grantee, 
                   to_number(substr(name,1,instr(name,':')-1)) userid, 
                   substr(name,instr(name,':')+1,instr(name,'#') - 
                          instr(name,':')-1) permition, 
                   substr(name,instr(name,'#')+1 ) action 
            from dba_java_policy 
            where grantee not in ('JAVADEBUGPRIV', 'JAVASYSPRIV', 
                                  'JAVAUSERPRIV', 'JAVA_ADMIN', 'JAVA_DEPLOY', 
                                  'SYS', 'PUBLIC') and 
                  type_name = 
                      'oracle.aurora.rdbms.security.PolicyTablePermission') a 
      where u.user#=userid) order by seq; 
column stmt clear 
set pagesize 24 
set heading on 
spool off 

Output from that script should produce Java recreation commands like:

exec dbms_java.grant_permission('SCOTT','SYS:java.io.FilePermission','temp\output.txt','read,write);

Conclusion

Recent surveys showed interesting answers to the question of 'why use Java'.

Some said because Java developers are easier to find than other developers, others are of the opinion that the development time is reduced due to Java code's simplicity and accessibility. Most of them believe that Java's performance will be comparable to other natively compiled languages in the future.

Once loaded, the Java option will need attention from a DBA.

When it is no longer needed, it should be removed, rather than just sizing down the Java pool.

» See All Articles by Columnist Marin Komadina








The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers