Re: setting global properites with Oracle's JVM
Date: Mon, 28 Feb 2000 15:06:35 -0700
Message-ID: <38BAF16B.4A23ADD0_at_mmm.com>
[Quoted] 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
steve perry wrote:
> I'm not sure if this is the right forum > > I have a request from our developers to set some global parameters for the > Oracle JVM. > For example, on our web servers they start the java runtime like jre -D > joeblow=true (or something like that). > > They've requested the same thing for the Oracle JVM. > We're running Oracle 8.1.5 on Sun 2.6 > I am not a java programmer and know very little about it (starting to learn > though :) ) > > When we create java sored procedures and then execute them, I assume that > oracle starts a jvm for that session (I don't see a "jre" using ps -ef in > unix though). The developers want to have some global properties they can > set. I assume they want to access them using > system.getproperties(joeblow). > > I called Oracle and they don't have any idea what I'm talking about. > > Any help would be appreciated > > Thanks, > steveReceived on Mon Feb 28 2000 - 23:06:35 CET