Databases Reference
In-Depth Information
identifier in Java. The Java program
JdbcInstrumentationOracle9i.java
in the source code
depot is instrumented with PL/SQL only and works with Oracle9
i
and subsequent releases.
Compiling the Program
Since there is a Java Developer's Kit (JDK) in an Oracle10
g
ORACLE_HOME
, there is no need to
install additional software to compile the Java program. It's sufficient to set the environment
variable
CLASSPATH
and to include the Java compiler
javac
in the command search path variable
PATH
. On UNIX, a colon (
:
) is used to separate individual entries in
CLASSPATH
, whereas on Windows
a semicolon (
;
) is used. Following is an example from Windows:
C:> set ORACLE_HOME=C:\Oracle\product\db10.2
C:> set CLASSPATH=%ORACLE_HOME%\jdbc\lib\ojdbc14.jar;.
C:> set PATH=%ORACLE_HOME%\bin;%ORACLE_HOME%\jdk\bin;%SystemRoot%\system32
C:> javac ApplicationInstrumentation.java
At this point, the compiled Java program is in the file
ApplicationInstrumentation.class
,
which is also included in the source code depot, such that you need not compile the source file.
Instrumentation at Work
Now it's time to run the program. Note that, since “.” was used in the
CLASSPATH
setting in the
previous section,
ApplicationInstrumentation.class
must be in the current directory to success-
fully run it. The program requires the following three arguments:
A database user name
The user's password
A JDBC URL for either JDBC Thin or JDBC OCI
JDBC OCI URLs take on the form
jdbc:oracle:oci:@
net_service_name
, where
net_service_
name
is a Net service name defined in
tnsnames.ora
or by a directory service. JDBC Thin URLs
port
/
instance_service_name
, where
host_name
is the system where the DBMS instance is running,
port
is the port number used by the listener, and
instance_service_name
is a service name listed
with
lsnrctl
services
. The old JDBC Thin URL syntax
jdbc:oracle:thin:@
host_
name
:
port
:
ORACLE_SID
should no longer be used, since it results in the default service name
SYS$USERS
in
V$SESSION.SERVICE_NAME
. This prevents the use of individual instance service
names for different applications and also defeats the purpose of cluster services in RAC
environments.
Setting Up Tracing, Statistics Collection, and
the Resource Manager
Some preparations are needed to show the interaction of instrumentation with end-to-end
tracing, client statistics collection, and the resource manager. The package
DBMS_MONITOR
may