 |
|
Using Oracle DropJava
Oracle Tips by Burleson Consulting
|
The DropJava utility drops individual Java
sources and binaries and entire JAR files. It also maintains the hash
table that LoadJava uses to track the loading of Java library units.
You can enter .java, .class, and .jar files on the command line in any
order. Here is the syntax:
dropjava
[{-v | -verbose}]
[{-t | -thin} | {-o | -oci81}]
[{-u | -user}
username/password@host_name:port_number:database_sid]
{filename.java | filename.class | filename.jar} ...
The following list presents the DropJava
command-line options:
Option
|
Description |
-v |
Enables verbose mode, in which
progress messages are displayed. |
-t | -o |
Selects the client-side JDBC
driver used to communicate with Oracle. You can choose the Thin
JDBC Driver (the default) or the OCI JDBC Driver. |
-u |
Specifies a database
connect string without spaces. The string includes a user name,
password, host-computer name, port number, and database system
identifier. If this option is not specified, the string defaults
to internal/oracle@localhost:1521:orcl. |
DropJava Examples
In the first example, DropJava drops various
Java binaries and resources. The utility reads the JAR files, then
drops each Java class or resource from your schema.
> dropjava
-u scott/tiger@myComputer:1521:orcl manager.jar
managerText.jar
In the next example, operating in verbose
mode, DropJava drops a Java class:
> dropjava
-v -u scott/tiger@myComputer:1521:orcl Calculator.class
...
files:
Calculator.class
dropping Calculator
Using CREATE Java
In Oracle8i and Oracle9i, Java, an
object-oriented development language, was added to the Oracle kernel.
In previous versions, Java, JDBC (Java Database Connectivity), and
SQLJ, Oracle’s PRO*Java product, provided connectivity to the
database, but Java was relegated to the outside, along with the other
languages, such as C, C++, FORTRAN, and COBOL. Now Java is allowed
inside the database. Java can be used for procedures, functions, and
methods and will be stored inside the database just like PL/SQL.
However, in order to move Java into the
database, a way had to be provided to bridge the gap between the
normal database lingua franca, PL/SQL, and the new Java classes. This
bridge between Java and PL/SQL is the Java object.
Creation of a Java Object
The Java object is created using the CREATE
JAVA command, which is documented in the SQL Reference Manual on the
documentation website. Java is stored in much the same way as PL/SQL
in database tables. Once called into memory (by standard function,
procedure, and method calls), it is placed in its own area. The area
where Java resides is appropriately called the Java Pool and is
configured at 20 MB by default but can be increased by use of the
JAVA_POOL_SIZE initialization parameter if required. Let’s look
at an example of the CREATE JAVA command.
Note: Java is not available until
version 8.1.4.
CREATE OR
REPLACE JAVA Source NAMED 'Login' AS
PUBLIC CLASS Login (
Public static String Login() (
Return 'You are logged into ORTEST1'; ) );
/
Use of the Java Object
A function or procedure call is wrapped around
the Java object in order to make it callable:
CREATE OR
REPLACE FUNCTION login
RETURN VARCHAR2 AS
LANGUAGE JAVA NAME 'Login() return String()';
/
Once the Java object is wrapped, it is called
just as the function or procedure would be called; in addition, the
object can be included in a package specification. The Login Java
object would be called like this:
SQL>
VARIABLE t VARCHAR2;
Finally, we are ready to call the function
Login. Remember, in a CALL statement, host variables must be prefixed
with a colon.
SQL> CALL
Login() INTO :t;
Call
completed.
SQL> PRINT t
t
—————————————-
You are logged into ORTEST1
For more complex examples, refer to the Java
Developer’s Guide.
Altering Java Objects
The ALTER JAVA command is used to alter Java
objects. The syntax for the ALTER JAVA command is:
ALTER JAVA
Source|CLASS [schema.]object_name
[RESOLVER ((match_string [,] schema_name|- ))
[COMPILE|RESOLVE] [invoker_rights_clause]
The ALTER JAVA command is only used to force resolution of Java
objects (compilation). The Java source must be in your own schema, or
you must have the ALTER ANY PROCEDURE, or the source must be declared
PUBLIC. You must also have EXECUTE privilege on the Java object.
An example use of the ALTER JAVA command is:
ALTER JAVA
CLASS "Agent"
RESOLVER (("D:\orant81\java\bin\*.*" , tele_Remote DBA)(* public))
RESOLVE;
Dropping Java Objects
If you don’t use the DropJava utility, you may
cause inconsistencies in Oracle internal tables; that is, the command
for dropping Java objects is:
DROP JAVA [schema.]java_name;
Memory and Java Objects
Java uses the shared pool and the Java pool.
The default in 8.1.3 for the Java pool is almost 10 MB; for the 8.1.4
beta it was upsized to 20 MB, and there it has remained. If you get
memory-related errors when dealing with Java objects, increase the
size of the Java pool. In Oracle9i the Java pool should be near 60
megabytes.
Error
reporting in out-of-memory situations is inconsistent and in some
cases may result in a core dump. If you suspect that memory
usage is the cause of a core dump, adjust the JAVA_POOL_SIZE in the
init.ora file. JAVA_POOL_SIZE should be set to 60,000,000 or higher
for large applications in Oracle9i. The default value of
20,000,000 in 8.1.4 and 8.1.5 should be adequate for typical Java
Stored Procedure usage before release 9i.
See
Code Depot for Full Scripts
 |
This is an excerpt
from Mike Ault, bestselling author of "Oracle
10g Grid and Real Application Clusters".
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |
 |
Expert Remote DBA
BC is America's oldest and largest Remote DBA Oracle support
provider. Get real Remote DBA experts, call
BC Remote DBA today. |
 |
|