Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

Java Overview

Problem

Description

Solution

Predictability

The class loading operation

 

places a severe penalty on

 

first-time execution. A simple

 

program can cause the Oracle

 

JVM to load many core classes

 

to support its needs. A

 

programmer cannot easily

 

predict or determine the

 

number of classes loaded.

Reliability

A benefit of dynamic class

 

loading is that it supports

 

program updating. For

 

example, you would update

 

classes on a server, and clients

 

who download the program

 

and load it dynamically see the

 

update whenever they next

 

use the program. Server

 

programs tend to emphasize

 

reliability. As a developer, you

 

must know that every client

 

executes a specific program

 

configuration. You do not

 

want clients to inadvertently

 

load some classes that you did

 

not intend them to load.

The Oracle JVM loads classes dynamically, just as with any other Java virtual machine. The same one-time class loading speed hit is encountered. However, because the classes are loaded into shared memory, no other users of those classes will cause the classes to load again—they will simply use the same pre-loaded classes.

Oracle separates the upload and resolve operation from the class loading operation at runtime. You upload Java code you developed to the server using the loadjava utility. Instead of using CLASSPATH, you specify a resolver at installation time. The resolver is analogous to CLASSPATH, but lets you specify the schemas in which the classes reside. This separation of resolution from class loading means you always know what program users execute.

Oracle’s Java Application Strategy

One appeal of Java is its ubiquity and the growing number of programmers capable of developing applications using it. Oracle furnishes enterprise application developers with an end-to-end Java solution for creating, deploying, and managing Java applications. The total solution consists of client-side and server-side programmatic interfaces, tools to support Java development, and a Java virtual machine integrated with the Oracle database server. All these products are compatible with Java standards.

In addition to the Oracle JVM, the Java programming environment consists of the following:

14-44 Oracle9i Database Concepts

Java Overview

Java stored procedures as the Java equivalent and companion for PL/SQL. Java stored procedures are tightly integrated with PL/SQL. You can call a Java stored procedure from a PL/SQL package; you can call PL/SQL procedures from a Java stored procedure.

SQL data can be accessed through JDBC and SQLJ programming interfaces.

Tools and scripts used in assisting in development, class loading, and class management.

Java Stored Procedures

If you are a PL/SQL programmer exploring Java, you will be interested in Java stored procedures. A Java stored procedure is a program you write in Java to execute in the server, exactly as a PL/SQL stored procedure. You invoke it directly with products like SQL*Plus, or indirectly with a trigger. You can access it from any Oracle Net client—OCI, PRO*, JDBC, or SQLJ.

The Oracle9i Java Stored Procedures Developer’s Guide explains how to write stored procedures in Java, how to access them from PL/SQL, and how to access PL/SQL functionality from Java.

In addition, you can use Java to develop powerful programs independently of PL/SQL. Oracle provides a fully-compliant implementation of the Java programming language and JVM.

PL/SQL Integration and Oracle RDBMS Functionality

You can invoke existing PL/SQL programs from Java and invoke Java programs from PL/SQL. This solution protects and leverages your existing investment while opening up the advantages and opportunities of Java-based Internet computing.

Oracle offers two different application programming interfaces (APIs) for Java developers to access SQL data—JDBC and SQLJ. Both APIs are available on client and server, so you can deploy the same code in either place.

JDBC Drivers—used to build client/server 2-tier applications

SQLJ – Embedded SQL in Java—used to access static SQL. You must know the name of the columns

JDBC Drivers JDBC is a database access protocol that enables you to connect to a database and then prepare and execute SQL statements against the database. Core Java class libraries provide only one JDBC API. JDBC is designed, however, to allow

SQL, PL/SQL, and Java 14-45

Java Overview

vendors to supply drivers that offer the necessary specialization for a particular database. Oracle delivers the following three distinct JDBC drivers.

Driver

Description

JDBC Thin Driver

You can use the JDBC Thin driver to write 100% pure

 

Java applications and applets that access Oracle SQL

 

data. The JDBC Thin driver is especially well-suited to

 

Web browser-based applications and applets, because

 

you can dynamically download it from a Web page just

 

like any other Java applet.

JDBC Oracle Call

The JDBC Oracle Call Interface (OCI) driver accesses

Interface Driver

Oracle-specific native code (that is, non-Java) libraries

 

on the client or middle tier, providing a richer set of

 

functionality and some performance boost compared to

 

the JDBC Thin driver, at the cost of significantly larger

 

size and client-side installation.

JDBC Server-side Internal

Oracle uses the server-side internal driver when Java

Driver

code executes on the server. It allows Java applications

 

executing in the server’s JVM to access locally defined

 

data (that is, on the same machine and in the same

 

process) with JDBC. It provides a further performance

 

boost because of its ability to use underlying Oracle

 

RDBMS libraries directly, without the overhead of an

 

intervening network connection between your Java

 

code and SQL data. By supporting the same Java-SQL

 

interface on the server, Oracle8i does not require you to

 

rework code when deploying it.

 

 

SQLJ – Embedded SQL in Java Oracle has worked with other vendors, including IBM, Tandem, Sybase, and Sun Microsystems, to develop a standard way to embed SQL statements in Java programs—SQLJ. This work has resulted in a new standard (ANSI x.3.135.10-1998) for a simpler and more highly productive programming API than JDBC. A user writes applications to this higher-level API and then employs a preprocessor to translate the program to standard Java source with JDBC calls. At runtime, the program can communicate with multi-vendor databases using standard JDBC drivers.

SQLJ provides a simple, but powerful, way to develop both client-side and middle-tier applications that access databases from Java. You can use it in stored procedures, triggers, methods within the Oracle environment. In addition, you can combine SQLJ programs with JDBC.

14-46 Oracle9i Database Concepts

Java Overview

The SQLJ translator is a Java program that translates embedded SQL in Java source code to pure JDBC-based Java code. Because Oracle provides a complete Java environment, you cannot only compile SQLJ programs on a client for execution on the server, but you can compile them directly on the server. The adherence of Oracle to Internet standards lets you choose the development style that fits your needs.

See Also: Oracle9i SQLJ Developer’s Guide and Reference

SQL, PL/SQL, and Java 14-47

Java Overview

14-48 Oracle9i Database Concepts

Соседние файлы в папке Oracle selected docs