Thursday, July 21, 2005

Java System Properties

SQL> COLUMN port_string FORMAT A40
SQL> SELECT dbms_utility.port_string port_string FROM dual
2 /

PORT_STRING
----------------------------------------
Linuxi386/Linux-2.0.34-8.1.0

SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "SystemProperty"
2 AS
3 public class SystemProperty
4 {
5 public static String Get(String property)
6 {
7 return (System.getProperty(property));
8 }
9 }
10 /

Java created.

SQL> CREATE OR REPLACE FUNCTION get_system_property (
2 property_name VARCHAR2
3 )
4 RETURN VARCHAR2
5 IS
6 LANGUAGE JAVA
7 NAME 'SystemProperty.Get(java.lang.String) return java.lang.String';
8 /

Function created.

SQL> COLUMN os_name FORMAT A20
SQL> COLUMN dump_separator FORMAT A20
SQL> SELECT get_system_property('os.name') os_name
2 , DUMP(get_system_property('line.separator')) dump_separator
3 FROM dual
4 /

OS_NAME DUMP_SEPARATOR
-------------------- --------------------
Linux Typ=1 Len=1: 10

SQL> connect user/pass@windows_box
Connected.
SQL> COLUMN port_string FORMAT A40
SQL> SELECT dbms_utility.port_string port_string FROM dual
2 /

PORT_STRING
----------------------------------------
IBMPC/WIN_NT-8.1.0
...
SQL> COLUMN os_name FORMAT A20
SQL> COLUMN dump_separator FORMAT A20
SQL> SELECT get_system_property('os.name') os_name
2 , DUMP(get_system_property('line.separator')) dump_separator
3 FROM dual
4 /

OS_NAME DUMP_SEPARATOR
-------------------- --------------------
Windows NT Typ=1 Len=2: 13,10

No comments: