|
Your organization
is now asking you to write a simple java program to identify a special problem
that can be classified by iselfschooling’s problems only.
|
More Resources by
Google: |
|
|
|
|
-- Hands-On 08 (JAVA Stream)
SET ECHO ON
CLEAR SCR
CLEAR SCR
-- Connect to SQLPLUS as the system/manager user.
--
pause
CONNECT system/manager
pause
CLEAR SCR
-- Check to see that you have the JAVA tool installed.
--
pause
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.
--
pause
CLEAR SCR
-- Also Check the JAVA pool memory usage.
--
pause
SELECT * FROM v$sgastat
WHERE pool LIKE 'java%'
/
-- You must have at least 30 megabytes of memory.
-- Notice that the amount of FREE MEMORY + MEMORY IN USE should
-- add up to more than 30 megabytes.
-- We have more than enough memory allocated for JAVA.
--
pause
CLEAR SCR
-- Connect to SQLPLUS as the iself user.
--
pause
CONNECT iself/schooling
pause
CLEAR SCR
-- Create an iself java class, to return the iselfschooling messages.
--
pause
CREATE OR REPLACE JAVA SOURCE NAMED "iself" AS
public class iself {
static public String message (String tail) {
return "iSelfSchooling-" + tail;
}
}
/
pause
CLEAR SCR
-- Publish the JAVA class to SQL by creating a PL/SQL
-- function.
-- Notice that JAVA programing is very case sensitive.
--
pause
CREATE OR REPLACE FUNCTION error_msg (str VARCHAR2)
RETURN VARCHAR2
AS
LANGUAGE JAVA NAME
'iself.message (java.lang.String)
return java.lang.String';
/
-- This is an example of how to call JAVA from PL/SQL in Oracle9i.
pause
CLEAR SCR
-- Test the error message function.
--
pause
SELECT error_msg ('01320: Running JAVA was successful.')
as "Message Function"
FROM dual
/
-- This is an example of the iselfschooling message function.
pause
CLEAR SCR
-- Drop the JAVA source and the error_msg function.
--
pause
DROP JAVA SOURCE "iself"
/
DROP FUNCTION error_msg
/
-- You have dropped the created objects so that you can repeat these
-- steps over and over again.
pause
CLEAR SCR
-- Now, Practice this hand-on over and over
-- until you become a master at it.
-- For more information about the subject, you are encouraged
-- to read from a wide selection of available books.
-- Good Luck!
pause
|