下面记录一下整个过程:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
SQL> select * from v$option t where t.PARAMETER='Java';
PARAMETER VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
Java TRUE
SQL> select distinct owner,name from dba_source where lower(NAME)='dbms_java';
OWNER NAME
------------------------------ ------------------------------
SYS DBMS_JAVA
SQL> select owner, status, count(*) from all_objects where object_type like '%JAVA%' group by owner, status;
no rows selected
于是要安装JVM:
@?/javavm/install/initjvm.sql
SQL> select owner, status, count(*) from all_objects where object_type like '%JAVA%' group by owner, status;
OWNER STATUS COUNT(*)
------------------------------ --------------- ----------
SYS VALID 19662
SQL> select comp_name, version, status from dba_registry;
COMP_NAME VERSION STATUS
---------------------------------------- ------------------------------ ---------------
Oracle Workspace Manager 11.1.0.7.0 VALID
Oracle Database Catalog Views 11.1.0.7.0 VALID
Oracle Database Packages and Types 11.1.0.7.0 VALID
@?/xdk/admin/initxml.sql
SQL> select owner, count(*) from all_objects where object_type like '%JAVA%' group by owner;
OWNER COUNT(*)
------------------------------ ----------
SYS 20738
@?/rdbms/admin/catjava.sql
SQL> select owner, count(*) from all_objects where object_type like '%JAVA%' group by owner;
OWNER COUNT(*)
------------------------------ ----------
SYS 21097
@?/rdbms/admin/catexf.sql
@?/xdk/admin/xmlja.sql
SQL> select owner, count(*) from all_objects where object_type like '%JAVA%' group by owner;
OWNER COUNT(*)
------------------------------ ----------
EXFSYS 44
SYS 21097
附加:
重新安装JVM在oracle11gr1
(1)关闭数据库,然后运行如下的脚本先删除现有的JVM:
-- Start of File full_rmjvm.sql
spool full_rmjvm.log
set echo on
connect / as sysdba
startup mount
alter system set "_system_trig_enabled" = false scope=memory;
alter system enable restricted session;
alter database open;
@?/rdbms/admin/catnoexf.sql
@?/rdbms/admin/catnojav.sql
@?/xdk/admin/rmxml.sql
@?/javavm/install/rmjvm.sql
truncate table java$jvm$status;
select * from obj$ where obj#=0 and type#=0;
delete from obj$ where obj#=0 and type#=0;
commit;
select owner, count(*) from all_objects
where object_type like '%JAVA%' group by owner;
select obj#, name from obj$
where type#=28 or type#=29 or type#=30 or namespace=32;
select o1.name from obj$ o1,obj$ o2
where o1.type#=5 and o1.owner#=1 and o1.name=o2.name and o2.type#=29;
shutdown immediate
set echo off
spool off
exit
-- End of File full_rmjvm.sql
说明:这一步可能会引发一些bug,请慎用!
(2)安装JVM的脚本:
-- Start of File full_jvminst.sql
spool full_jvminst.log;
set echo on
connect / as sysdba
startup mount
alter system set "_system_trig_enabled" = false scope=memory;
alter database open;
select obj#, name from obj$
where type#=28 or type#=29 or type#=30 or namespace=32;
@?/javavm/install/initjvm.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/xdk/admin/initxml.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/xdk/admin/xmlja.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/rdbms/admin/catjava.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
@?/rdbms/admin/catexf.sql
select count(*), object_type from all_objects
where object_type like '%JAVA%' group by object_type;
shutdown immediate
set echo off
spool off
(3)检查JVM及一些安装包的状态
connect / as sysdba
spool jvm_stats.log
set serveroutput on
set echo on
set pagesize500
set linesize 100
column comp_name format a40
select comp_name, version, status from dba_registry;
select owner, status, count(*) from all_objects
where object_type like '%JAVA%' group by owner, status;
select owner, object_type, count(*) from all_objects
where object_type like '%JAVA%' and status 'VALID' group by owner, object_type;
select owner, status, object_type, object_name from all_objects
where object_name like'%DBMS_JAVA%';
select owner, status, object_type, object_name from all_objects
where object_name like'%INITJVMAUX%';
select role from dba_roles where role like '%JAVA%';
select * from v$sgastat where POOL = 'java pool' or NAME = 'free memory';
show parameter pool_size
show parameter target
show parameter sga
select owner, object_type, status, dbms_java.longname(object_name) from all_objects
where object_type like '%JAVA%' and status 'VALID';
spool off
/