15-13. Removing a Java Class

Problem

You want to drop a Java class from your database.

Solution

Issue the SQL DROP JAVA command along with the schema and object name you want to drop. For instance, you want to drop the Java source for the Employees class. In this case, you would issue the following command:

DROP JAVA SOURCE “Employees”;

How It Works

There may come a time when you need to drop a Java class or sources from the database. For instance, if you no longer want to maintain or allow access to a particular Java class, it may make sense to drop it. The DROP JAVA SOURCE command does this by passing the name of the class or source as demonstrated within the solution to this recipe.

Image Note Be careful not to drop a Java class if other Java procedures or PL/SQL call specifications depend upon it. Doing so will invalidate any dependent code, and you will receive an error if you try to execute. The data dictionary provides views, such as DBA_DEPENDENCIES, that can be queried in order to find dependent objects.

Alternately, if you are on the database server, there is a dropjava utility that works in the same fashion as the loadjava utility that was demonstrated in Recipe 15-3. To use the dropjava utility, issue the dropjava command at the command line, and pass the database connect string using the –u flag along with the name of the Java class or source you want to drop. The following example demonstrates the command to drop the Employees Java class using the dropjava utility.

dropjava –u username/password@database_host:port:database_name Employees.class

The dropjava utility actually invokes the DROP JAVA SOURCE command. The downside to using the utility is that you must be located on the database server to use it. I recommend using the DROP JAVA SOURCE command from SQL*Plus if possible because it tends to make life easier if you are working within SQL*Plus on a machine that is remote from the server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.180.133