user12703
user12703

Reputation: 65

Modifying JVM parameters at runtime

Does someone know if it is 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).

Upvotes: 0

Views: 2298

Answers (4)

Saber Chebka
Saber Chebka

Reputation: 107

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"

Upvotes: 1

Asgeir S. Nilsen
Asgeir S. Nilsen

Reputation: 1137

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.

Upvotes: 0

shadit
shadit

Reputation: 2566

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.

Upvotes: 0

Nicholas Riley
Nicholas Riley

Reputation: 44321

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

Upvotes: 5

Related Questions