I am still
determined to be cheerful and happy, in whatever situation I may
be; for I have also learned from experience that the greater
part of our happiness or misery depends upon our dispositions,
and not upon our circumstances. Martha Washington (1732 -
first then play the video:
to use JAVA Stream
Calling JAVA Stream in
Your organization is now
asking you to write a simple java program to identify a special
problem that can be classified by iselfschoolings problems only.
You have been assigned to:
1- Check for a successful
installation of initjvm.sql,
2- Check JAVA pool memory
3- Create the JAVA class,
4- Publish the JAVA program
Connect to SQLPLUS as the
SQL> CONNECT system/manager
Check to see that you have
the JAVA tool installed.
SQL> SELECT COUNT(*) FROM dba_objects
WHERE object_type LIKE 'JAVA%'
This response, indicates that the JAVA tool was previously
installed successfully. If you get a number less than 1200, you may
have had problems with the installation process. And we recommend that
you re-install the JAVA component.
JAVA pool memory usage
Also Check the JAVA pool
SQL> SELECT * FROM v$sgastat
WHERE pool LIKE 'java%'
You must have at least 30 megabytes of memory.
Notice that the amount of MEMORY + MEMORY IN USE should add
up to more than 30 megabytes.
If you have enough memory allocated for JAVA. Connect to SQLPLUS as
the iself user.
SQL> CONNECT iself/schooling
Create a JAVA class
Create an iself java class,
to return the iselfschooling messages.
CREATE OR REPLACE JAVA SOURCE NAMED
public class iself
static public String message (String tail)
return "iSelfSchooling-" + tail;
Publish a JAVA class
Publish the JAVA class to
SQL by creating a PL/SQL function. Notice that JAVA programing is very
CREATE OR REPLACE FUNCTION error_msg
LANGUAGE JAVA NAME
This is an example of how to call JAVA from PL/SQL in
Test a JAVA function
Test the error message
SQL> SELECT error_msg ('01320: Running
JAVA was successful.')
as "Message Function"
This is an example of the iselfschooling message function.
DROP a JAVA source
Drop the JAVA source and
the error_msg function.
SQL> DROP JAVA SOURCE "iself"
Drop a JAVA function
SQL> DROP FUNCTION
error_msgYou have dropped the created objects so that you can repeat
these steps over if you wish.
The farther behind
I leave the past, the closer I am to forging my own character.
Q: How do you check that
you have the JAVA tool installed in your server?
Q: What should it be a
least size for the JAVA pool memory usage?
Q: How do you create a JAVA
Q: How do you publish a
Q: How do you test a JAVA
Q: How do you drop a JAVA
source and Function?