Table of Contents
Part I: Basic Oracle8i SQLJ.
Introduction to Oracle8i SQLJ.
SQLJ Program Development.
Basic SQLJ Programming.
Part II: Advanced SQLJ for Relational Processing.
Developing SQLJ Stored Programs and Triggers.
Advanced SQLJ Deployment.
Advanced SQLJ Features.
Part III: SQLJ and Object Deployment.
Object-Relational Processing Using SQLJ.
SQLJ Business and Scientific Object-Deployment.
Part IV: Effective Use of SQLJ.
SQLJ Applications: Performance Tuning.
Part V: Appendices:
A: Basic Oracle SQL.
B: Java Basics.
C: Introduction to Java Database Connectivity (JDBC).
D: SQLJ Quick Reference Guide.
Read an Excerpt
Chapter 1: Inrtroduction to Oracle8i SQLJ
Relation of the Java Language to Database Processing on the Internet
Java is a modern, object-oriented programming language that borrows heavily from the syntax and semantics of the C and C++ programming languages. Its initial popularity came from its capability for developing client-based applications and adding dynamic content to Web pages. Over the last several years, however, Java has matured from a programming language used to develop client-based programs, in particular Graphical User Interface (GUI) programs, to a platform for developing and deploying applications at all levels of an organization by distributing applications over networks using Internet/intranet capabilities (that is, enterprise applications).
Java facilitates the development of robust and portable programs. Like with most modern programming languages, Java is object-oriented from the ground up. This contributes to the robustness of applications developed in the language. Additionally, Java provides mechanisms that help developers produce robust code, including early (compile) checking, later dynamic (runtime) checking, and a pointer model that eliminates the possibility of overwriting memory and corrupting data. Some of Java's other features that contribute to robustness are automatic storage management (referred to as garbage collection) and type-safety. Such features make Java ideal for server-side programming, where a server crash can be quite costly in terms of time and money. Java defines both a language and a set of standard class libraries (Java packages) that ensure that applications can be constructed to run on any Java Virtual Machine (JVM)or in any other environment. The JVM is an interpreter for Java, and therefore a program that can be ported from one machine architecture to another with minimal change. The JVM is responsible for controlling the Java execution environment and obtaining resources from the computer hardware. Java programs are compiled into compact intermediate code (Java's bytecode) that has no direct correspondence to any given item of hardware. Also, the fact that Java is interpreted makes it easier for the system to perform runtime error checking, further enhancing the robustness of Java programs.
Traditional design and development strategies create monolithic systems. A monolithic system corresponds to a single application, running or executing on a single computer. Business and scientific applications are becoming far more complex than they have ever been. Therefore, their designers are turning to techniques such as distributed systems in response to the increased pressure to better manage and manipulate information. Java provides a platform and framework for developing and deploying applications for today's complex information systems. The Java language, with its component-based models, enables users to assemble, partition, and distribute application components across a network. Java's components consist of a set of platform-independent services, such as Remote Method Invocation (RMI), JavaBeans, and Enterprise JavaBeans (EJB). RMI is a standard Java facility that makes it possible to invoke Java methods remotely, whereas EJB is an architecture for developing transactional applications as distributed components in Java. See Chapter 8 for a tutorial on building RMI, EJB, and CORBA objects.
Java facilitates Internet/intranet development applications. Its virtual machine-based organization defines a highly compact set of bytecodes, which can be efficiently transported in the Internet/intranet environment. Java offers the power to unify the infrastructure of today's computing environment where mission-critical and i nd ustri al -strength servers are still heterogeneous. Distributed applications with components that need to communicate across multiple systems in a network can use Java to do so. Java supports many standard communication protocols, including TCP/IP (Transmission Control Protocol/Internet Protocol), HTTP (Hypertext Transfer Protocol), and HOP (CORBA's Internet Interoperability Protocol).
Java applets, servlets, and applications are appearing all over the Web, bringing rich functionality to what was before a static medium. Leading hardware vendors, infrastructure providers, and software vendors provide support for building extensible applications across all tiers, as well as tools to Web-enable existing client/server applications. Leading browser platforms are building Java Virtual Machines into their systems. Database vendors, such as Oracle and Informix, are integrating Java Virtual Machines with their data servers.
Tight Integration of Java and the Oracle8i Database Server
Prior to the release of Oracle8i, Oracle application developers used PL/SQL to develop server-side applications that have tight integration with SQL data. PL/SQL is an Oracle RDBMS procedural language extension to SQL. The language integrates features such as exception handling, overloading, and a limited amount of information hiding (accomplished by declaring variables and types in a package body instead of a package specification). In addition to providing these capabilities, PL/SQL subprograms (procedures and functions) and triggers can be stored in the Oracle database server. A subprogram consists of a set of PL/SQL statements that are grouped together as a unit to perform a set of related tasks. They are created and stored in compiled form in the database. Additionally, application programmers can create PL/SQL packages. Packages provide a method of encapsulating and storing related procedures, functions, variables, and other packages constructed together as a unit in the data server. All objects are parsed, compiled, and loaded into memory once. Stored procedures and packages, because of their central location, can be called and executed by users and other database applications. These capabilities offer increased functionality, network traffic reduction, and application and system performance. See Appendix A for a tutorial on PL/SQL.
The Oracle8i Database Server, Oracle8ij Server, supports two major programming languages, Java and PL/SQL. Both languages seamlessly interoperate and complement each other in the database. SQL and PL/SQL can call Java methods. A Java stored procedure is a program written in Java to execute in the Oracle )Server. Java stored procedures can be called directly with products such as SQL*Plus or indirectly with a trigger and can be accessed from any Net8 client-OCI, PRO*, JDBC, or SQLJ. Java can also call SQL and PL/SQL, via either JDBC or SQLJ. Since the JServer provides a fully compliant implementation of the Java programming language and Virtual Machine, Java developers can develop Java programs independently of PL/SQL.
The Oracle )Server includes a Java Virtual Machine (JVM) and a Java execution environment. Since Java is an interpreted language (interpreted by the JVM) it faces a performance penalty when compared with languages like C or C++. A Java program can run very slowly, and this can be a real problem for Java applications. To address this problem, Oracle delivers the core Java class libraries (such as java. lang), the Aurora/ORB (Object Request Broker), and JDBC code in natively compiled form. Standard Java classes, such as java.lang. *, exist in shared libraries. Thus, the developer's Java code, which is loaded in the JServer, is interpreted, while the standard classes on which this code relies are fully compiled.
The JVM is embedded in the Oracle data server with native compilation and optimization and is compatible with the Java standard. The Java Virtual Machine executes Java programs on the Oracle8i Server. Java applets and applications can access Oracle8i via JDBC and/or SQLJ. The integration of the Java Virtual Machine in the data server expands Oracle's support for Java into all tiers of applications, allowing Java programs to be deployed in the client, server, or middle-tier. Using Java and Oracle8i, Java programmers can build and deploy server-based Java applications shared by all clients. These applications can easily be distributed across networks, providing access to Oracle data from any computer that supports Java...