Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: setting global properites with Oracle's JVM

Re: setting global properites with Oracle's JVM

From: Gary Fowler <grfowler_at_mmm.com>
Date: Mon, 28 Feb 2000 16:01:35 -0700
Message-ID: <38BAFE4F.56ECB022@mmm.com>


Sorry I had a typo in the PropertyTest.java source code. The method name should be getProperty instead of getProperty2.

Gary Fowler wrote:

> If you're doing EJB, you can set Environment Properties in you ejb descriptor.
> You can then access them through the SessionContext of the session bean:
>
> Properties props = ctx.getEnvironment();
> String someValue = props.get("someKey");
>
> For straight Java Stored Procedures, you can load a properties file as a
> resource with the loadjava tool.
> You can then add them to the System properties via
> System.setProperties(Properties) method. Once set
> you should be able to access them via the System.getProperty(String) method for
> the duration of you database session. In other words call the loadProperties
> stored procedure at the beginning of each database session.
>
> **************
> PropertyTest.java
> **************
> import java.io.*;
> import java.util.*;
>
> public class PropertyTest
> {
> public static void loadProperties() throws IOException
> {
> Properties props = new Properties(System.getProperties());
> props.load(new
> PropertyTest().getClass().getResourceAsStream("test.properties"));
> System.setProperties(props);
> }
>
> public static String getProperty2(String key)
> {
> return System.getProperty(key);
> }
> }
>
> ***********
> test.properties
> ***********
> portNumber=4444
> compilerCommand=/usr/db/delphi/bin/expl -b
>
> ***************
> loadjava command
> ***************
> loadjava -oracleresolver -resolve -user joe/blow PropertyTest.java
> test.properties
>
> *******
> call specs
> *******
> create or replace procedure loadProperties
> as language java
> name 'PropertyTest.loadProperties()';
>
> create or replace function getProperty (key varchar2) return varchar2
> as language java
> name 'PropertyTest.getProperty(java.lang.String) return java.lang.String';
>
> ************
> test it in sqlplus
> ************
> SQL> variable v varchar(50)
> SQL> call loadProperties();
>
> Call completed.
>
> SQL> call getProperty('portNumber') into :v;
>
> Call completed.
>
> SQL> print v
>
> V
> ----------------------------------------------------------------------------------------------------------------
>
> 4444
>
> SQL> call getProperty('compilerCommand') into :v;
>
> Call completed.
>
> SQL> print v
>
> V
> ----------------------------------------------------------------------------------------------------------------
>
> /usr/db/delphi/bin/expl -b
>
> I hope this helps,
> Gary Fowler
> 3M Health Information Systems
> grfowler_at_mmm.com
>
Received on Mon Feb 28 2000 - 17:01:35 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US