everythingOracle.bizhat.com

 

'Everything you wanted
to know about Oracle'

Training References Syntax Tell A Friend Contact Us

 

 

Manuscript: 11

 

 

Topics: Hands-On 08

 

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.

 

   
   

Manuscript

-- 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 oracle user.
--
pause

CONNECT oracle/learning
pause


CLEAR SCR
-- Create an oracle java class, to return the everythingoracle messages.
-- 
pause

CREATE OR REPLACE JAVA SOURCE NAMED "everythingoracle" AS 
public class everythingoracle { 
static public String message (String tail) { 
return "everythingOracle-" + 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 
'everythingoracle.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 everythingoracle message function.
pause

CLEAR SCR
-- Drop the JAVA source and the error_msg function.
--
pause
DROP JAVA SOURCE "everythingoracle"
/

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

 

     Reviews and Templates for FrontPage
     

Copyright � everythingOracle.bizhat.com 2006 All Rights Reserved.