Oracle
  Home arrow Oracle arrow Page 4 - Extending PL/SQL with Java Libraries
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Extending PL/SQL with Java Libraries
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2006-01-12

    Table of Contents:
  • Extending PL/SQL with Java Libraries
  • Java Architecture in Oracle
  • Oracle JDBC Connection Types
  • Building Java Class Libraries in Oracle
  • Building Internal Server Java Functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Extending PL/SQL with Java Libraries - Building Java Class Libraries in Oracle
    (Page 4 of 5 )

    When you choose to build Java class libraries, you have two deployment choices. You can build call-interface driven (middle-tier) or server-side Java class libraries.

    Call-interface libraries act like server-side includes to your Apache server. They must be replicated to all nodes of your Apache server and are managed within the structure of your web server load-balancing tool. These components act like external programs that call into the Oracle server and are better treated in Enterprise Java books.

    Why Would I Use This?

    You need to know when a Java class belongs as an internal or external library. We find Java libraries deployed internally in the database have well-defined but narrow uses. Likewise, we find external libraries to be powerful components but less convenient than locally stored objects. You will need to understand these two technologies to make good deployment choices.

     

    NOTE

    While call-interface driver or middle-tier Java class libraries are not directly covered, they do require direct reference in their path to the Oracle OCI libraries. The OCI libraries are in the Oracle Application Server but not on other web servers.

    Server-side Java class libraries are stored objects within the Oracle JVM, which is a subcomponent of the Oracle database. Server-side Java class libraries are the core theme of this chapter. In the next two sections, you’ll learn how to build internal server Java functions and procedures.

    NOTE

    If you’re unfamiliar with configuring and testing a Java JDBC connection, please check Appendix D for instructions.

    Java programming ranges from simple to complex, but these examples should be straightforward. You have two core executables to run Java programs, which you’ll use in the examples. They are

    • javac   Compiles your text file Java programs into Java byte code
    • java   Runs your compiled Java byte code programs

    The file-naming convention in Java is case-sensitive so you should ensure you name files consistent with the web-based code example files. If you attempt to compile a Java file when the file name and class name are different, you’ll receive an error. Also, the file extension for Java programs is a lowercase .java.

    You’ll now build a simple HelloWorld1.java file to make sure the balance of the examples works. If you’re working in Microsoft Windows, please open a Command Prompt Window. If you’re working in UNIX, please use a terminal window. The following is the code for HelloWorld.java:

    -- Available online as part of HelloWorld1.java file.
    // Class definition.
    public class HelloWorld1
    {
      // --------------------------------------/
      // Static main to print Hello World. 
      public static void main(String args[])
      { 
        
    // Print the message to console.
        System.out.println("Hello World.");
      } // End of static main.
      // --------------------------------------/
    } // End of HelloWorld1 class.

    Java text files are compiled by the following syntax:

    javac HelloWorld1.java

    Successful compilation does not return anything to the console. The lack of any message is a good thing. The way to verify whether or not you have a Java byte code file is to run the Microsoft Windows directory (dir) command or UNIX list (ls) command for files matching HelloWorld1.* in the present working directory. You should see two files displayed to the console:

    HelloWorld1.java
    HelloWorld1.class

    After building the Java byte code compiled program, you can test its execution by doing the following:

    java HelloWorld1

    NOTE

    You do not provide the .class extension when running Java programs because it is assumed. Appending .class to the file name will raise the following exception: java.lang.NoClassDefFoundError: HelloWorld1/class.

    TIP

    You can also raise the java.lang .NoClassDefFoundError: HelloWorld1/class error if you do not have your present working directory in your PATH and CLASSPATH environment variables.

    You’ll receive the following results:

    Hello World.

    The next section covers how you build server-side or internal server Java programming units. You’ll learn how to build Java class files to support stored functions and procedures and how to wrap their existence in PL/SQL packages. The following two sections are sequential and the second section assumes you have worked through the first.

    More Oracle Articles
    More By McGraw-Hill/Osborne


       · This article is an excerpt from the book "Expert Oracle PL/SQL," published by...
     

    Buy this book now. This article is excerpted from chapter five of Expert Oracle PL/SQL, written by Ron Hardman and Michael McLaughlin (McGraw-Hill/Osborne, 2005; ISBN: 0072261943). Check it out today at your favorite bookstore. Buy this book now.

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway