Free Newsletters:
Database Journal  
DBAnews  

DBASupport

 The Knowledge Center for Oracle Professionals

Search DBAsupport:
 
HOME 11g Central 10g Central 9i Central 8i Central Oracle News Scripts FAQ OCP Zone Resources Technical Docs Tools & Utilities Forums
internet.com

» HOME
» FEATURES
    11g Central
    10g Central
    9i Central
    8i Central
    Oracle News
» COMMUNITY
    Scripts
    Forums
    FAQ
    OCP Zone
» RESOURCES
    Resources
    Technical Docs
    Tools & Utilities
    Tech Jobs


internet.commerce
Be a Commerce Partner
Find Project Software
PDA Phones & Cases
Car Donations
Logo Design
Promotional Products
Imprinted Gifts
Web Hosting Directory
Compare Prices
GPS
Shop Online


internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


   DBAsupport.com > Oracle > Java Center


Solaris 8 Migration Assistant
Rapidly move your Solaris 8 application environments to new systems running Solaris 10 with the Solaris 8 Migration Assistant. Reduce migration risk while taking advantage of increased performance, reliability and security of the latest SPARC hardware platforms and Solaris 10 OS. »

 
Sun Partner Survey
Please take a quick 3 minute survey from Sun. Click here to take the survey. Your feedback will help Sun improve on their solution center and be more useful for you and your peers. Thank you for your time and consideration. »

 
Sun Eco Innovation: Power Calculators
Power consumption has increasingly become a priority in customer's minds when purchasing new systems or storage. Sun's Power Calculators provide data on power consumption of Sun products allowing IT managers to better plan the power requirements in the datacenter to achieve better energy and cost savings. »

 
Optimize the Web Tier: Consolidate to Get More Performance in Less Space and Lower Power Consumption
Expansion in the Web tier is generally accomplished by adding more servers whenever extra capacity is needed. As the pool of servers grows larger, however, the complexity of the environment can grow exponentially. »


Intel Whitepaper: Improve Security and Control of Your PCs

Sr. Oracle EBS Developer
Professional Technical Resources
US-OR-Forest Grove

Justtechjobs.com Post A Job | Post A Resume

Java Stored Procedures and Functions are Java methods stored in the database. They are published to the SQL using call specifications which map the method names, parameters and return types to the SQL Context.

An Overview of Java Stored Procedure / Function Development

1. Write the procedure in Java using your favourite editor. I prefer KAWA since it is very flexible and does not have all the clutter of GUI designers.

2. Oracle provides a loadjava utility that can be used to Load Java Classes into the database.

3. Write Call Specs so that these Java Procedures are exposed to the SQL Context. In this step we will write a call spec to the top level entry point of Java Method.

4. Call Java Stored Procedures / Funcations as if they were PL/SQL Stored Procedures.

Lets start by creating a simple procedure that will print hello world. This example is very basic and will only introduce the concept of java stored proc creation in the database.

Create Procedure and save as Dba.java

Step 1: Open Notepad, and create a Class named Dba with a single method in the class called printHello. The method printHello will take no arguments and print a string "Hello World". Here is the code for the procedure. JaVa is Case SeNsItIvE, so be careful.

// Dba.java
// Save the file with the same name as the public class


import java.util.*;

public class Dba
{
public static void printHello ()
{
String prtString="Hello World";
System.out.println(prtString);
}
}

Load the Class Dba

Oracle 8i comes with a handy utility called loadjava that loads classes into the database. Load the java source file you just created, using the loadjava utility. I saved my file as C:\java\Dba.java, change the following code to your environment. NOTE: file name should exactly match the class name

C:\ cd java
C:\ loadjava -u scott/tiger -resolve C:\java\Dba.java

Java source code can be loaded into the database to let the database handle the compilation or a pre compiled java class can be loaded using loadjava. In the above case the java source code is being loaded.

Publish in Oracle Data Dictionary

Publishing a java method is nothing but declaring a function or a procedure in PL/SQL using Create function or create procedure based on the return value of the method. If the method returns a value, declare it as a function or else it can be declared as a procedure. Log into sql plus as scott/tiger and

SQL>CREATE OR REPLACE PROCEDURE printHello
AS LANGUAGE JAVA
NAME 'Dba.printHello()';
/

Execute the Java Procedure

After you load and publish the stored procedure, you are ready to call it. Since we are using a System.out. and System.err print to the trace files by default. so, use a simple work by calling the dbms_java.set_output();

SQL>set SERVEROUPUT ON;
SQL>CALL dbms_java.set_output(1000);
SQL>CALL printHello();

IF you have any questions please post them in the java forum.


DBAsupport.com Home Page







JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES