tags:

views:

905

answers:

5

Does someone know if it's possible to modify the jvm settings at runtime (e.g. -dname=value) ? I need this little trick to run my java stored procedure (oracle 10g)...

Thanks a lot.

P.S.Sorry for my bad English.

+5  A: 

Assuming you mean system properties (-D...; -d picks data model) System.setProperty(...) may do what you want.

Nicholas Riley
Also, keep in mind that a few system properties won't have any effect if set at runtime.
jsight
AND keep in mind that the SecurityManager currently in charge has to agree with you changing them System properties...
Aleksandar Dimitrov
A: 

You can definitely set system properties in a Java stored procedure using System.setProperty(). But, they will only be available to the current Oracle session.

For example, if you connect to Oracle, and run a Java stored procedure that sets system properties, then disconnect from Oracle. When you next connect to Oracle, the system property will not be present. Each session with Oracle has its own pseudo-separate JVM (even though all sessions really share a single JVM).

If the account you are using for your Oracle session has sufficient rights, you can run external operating system commands including a separate, external JVM.

shadit
A: 

You can change a system property using System.setProperty(), but whether or not this has an effect really depends on that system property. Some properties are read statically, i.e. at class loading time, and others might cache the value in some object field.

Asgeir S. Nilsen
A: 

Questions like this beg for a view of the bigger picture.

What is the over-all objective? Maybe there is a better path....

willCode4Beer
A: 

You can use the OracleRuntime class inside your java stored procedure.

    int times = 2;
 OracleRuntime.setMaxRunspaceSize(times *OracleRuntime.getMaxRunspaceSize());
 OracleRuntime.setSessionGCThreshold(times *OracleRuntime.getSessionGCThreshold());
 OracleRuntime.setNewspaceSize(times *OracleRuntime.getNewspaceSize());
 OracleRuntime.setMaxMemorySize(times *OracleRuntime.getMaxMemorySize());
 OracleRuntime.setJavaStackSize(times *OracleRuntime.getJavaStackSize());
 OracleRuntime.setThreadStackSize(times *OracleRuntime.getThreadStackSize());

This sample code multiplies by 2 memory status in oracle jvm. Note: import oracle.aurora.vm.OracleRuntime; will be resolved on oracle jvm, found on "aurora.zip"

Saber Chebka