简体   繁体   中英

How do you set a System property in the Oracle 10g JVM without using System.setProperty() directly?

如何在不直接使用System.setProperty()的情况下在Oracle 10g JVM中设置系统属性?

On the command line you can set -Dproperty=value

Or you can use System.getProperties().setProperty() or System.getProperties().put()/putAll()

Why would you want to set properties indirectly? Can you give an example?

I'll assume that you're referring to the JVM within an Oracle 10g database. If that is the case, then (inferring from the Oracle 10g database documentation for DBMS_JAVA here), it is not possible to set the properties for a Java session from an RDBMS session. The only choice therefore is to pass in values to the Java session and then invoke System.setProperty().

On the otherhand, it appears to be possible in the 11g database, if one goes by the 11g documentation :

Setting System Properties

Within an RDBMS session you can maintain a set of values that are added to the system properties whenever a Java session is started in the RDBMS session. This set of values remains valid for the duration of the longer tier of Java session state, which is typically the same as the duration the RDBMS session.

There is a set of PL/SQL functions in the DBMS_JAVA package for setting, retrieving, removing and displaying key value pairs in an internal, RDBMS session duration table, where both elements of a pair are strings (VARCHAR2) and there is at most one pair for a given key. These functions are as follows:

  • set_property
  • get_property
  • remove_property
  • show_property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM