Oracle
  Home arrow Oracle arrow Page 4 - Extending PL/SQL with Java Libraries
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBMョ developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
ORACLE

Extending PL/SQL with Java Libraries
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 8
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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値l learn how to build internal server Java functions and procedures.

    NOTE

    If you池e 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値l 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値l receive an error. Also, the file extension for Java programs is a lowercase .java.

    You値l now build a simple HelloWorld1.java file to make sure the balance of the examples works. If you池e working in Microsoft Windows, please open a Command Prompt Window. If you池e 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値l receive the following results:

    Hello World.

    The next section covers how you build server-side or internal server Java programming units. You値l 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
     

       

    ORACLE ARTICLES

    - Oracle's Turn to Play in the Sun
    - Implementing and Using Oracle`s Restore Poin...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek