See Oracle Managed Errors for Java related errors on Oracle |
See WriteToFile.java.sql how to write a file from Oracle, My Java Utilities various utilities methods, Web Services how to set up Oracle to support Web Services calls, Java tunnel Oracle-OS access the OS from sqlplus! Array between Oracle and Java Passing an array between Oracle and Java Privileges and grants See http://developers.sun.com/product/jdbc/drivers for a list of JDBC drivers officially supported
Verify installation select count(*) from dba_registry where comp_id = 'JAVAVM' |
Install JServer java_pool_size >30M and shared_pool_size >50M INIT.ORA parameter values. [s.sql] alter system flush shared_pool; @?/javavm/install/initjvm.sql #this is optional, and at the moment not tested @?/javavm/install/catjava.sql alter system flush shared_pool; exit nohup sqlplus "/ as sysdba" @s & Grants GRANT JAVAUSERPRIV TO SCOTT; |
Removing JVM nohup sqlplus "/ as sysdba" @?/javavm/install/rmjvm.sql & alter system flush shared_pool; A shutdown abort is often required Supplied removal sucks! Let's do it by hand. This manual way works! Remove anything from obj$ relating java (^^lol!) #do not remove SYS.JAVASNM$ this table is needed by package rmjvm drop table sys.JAVA$RMJVM$AUX3; drop table sys.JAVA$RMJVM$AUX2; drop table sys.JAVA$RMJVM$AUX; drop table sys.JAVA$JVM$STEPS$DONE; drop table sys.JAVA$JVM$STATUS; drop package sys.RMJVM; drop package sys.INITJVMAUX; |
Installing with loadjava #After loading reconnect any client java user, the old classes may be used. Flushing the shared pool does not works #using SID loadjava -thin -user "periscope/periscope@172.18.20.68:1521:CLAR" -grant public -r -v -f servlet.jar #using SERVICE NAME loadjava -thin -user "strmadmin/strmadmin@dbd0227-grid.nl.eu.abnamro.com:1521/mtg.a.de.grid" -grant public -r -v -f CaptureMTS.jar -genmissing Use this option when a class is not present, but required, and you want it to be automatically generated Removing single classes select 'DROP JAVA CLASS "' || owner || '"."' || name || '";' from dba_java_classes where name like 'javax/servlet/%' and owner='PERISCOPE' DROP JAVA CLASS "PERISCOPE"."javax/servlet/ServletInputStream"; |
Troubleshooting
DOC>*/
call rmjvm.check_for_rmjvm()
*
ERROR at line 1:
ORA-00028: your session has been killed
ORA-06512: at "SYS.RMJVM", line 447
-------
restart db, remove, restart db, install |
Redirecting Output on the Server --From sqlplus: SET SERVEROUTPUT ON SIZE 5000 CALL dbms_java.set_output(5000); |
Test class
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED Test as
public class Test {
public static void main (String args[]) {
System.out.println("This is a test");
}
} |
Compile classes SQL> ALTER java class PERISCOPE."com/periscope/core/ConnectionBean" COMPILE; Warning: Java altered with compilation errors. SQL> show errors java class PERISCOPE."com/periscope/core/ConnectionBean"; Compile sources SQL> ALTER java source PERISCOPE."Generated/TESTSTAPI" compile; Warning: Java altered with compilation errors. SQL> show error java source PERISCOPE."Generated/TESTSTAPI" |
Static variables Java static variables are retained for the entire Oracle session duration, and are not shared with other sessions. This allow the creation of a session repository. Allocation occurs in PGA. Be very aware of possible session state clear... |
Are we on the server?
System.getProperty ("oracle.jserver.version")
|
JDBC Connection tips
!!Do not span connect string on multiple lines!!
Connect String - standard
#for sysdba you must use Properties.put("internal_logon", "sysdba");
jdbc:oracle:thin:@ + hostname + : + port + : + sid
Connect String - load balanced
jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=al12)))
|
Permissions
begin
dbms_java.grant_permission('SYSTEM','java.io.FilePermission','/usr/bin/*','read ,write, execute, delete');
end;
select * from DBA_JAVA_POLICY
where grantee = 'SYSTEM'
begin
dbms_java.revoke_permission('SYSTEM','java.io.FilePermission','/usr/bin/*','read ,write, execute, delete');
end;
select enabled, seq from DBA_JAVA_POLICY
where grantee = 'SYSTEM'
begin
DBMS_JAVA.DISABLE_PERMISSION(59);
dbms_java.delete_permission(59);
end;
#or
delete from java$policy$ where key in (181, 182, 183, 201);
commit;
alter system flush shared_pool;
|