SHARE
Facebook X Pinterest WhatsApp

Oracle in a Nutshell

Mar 10, 2003

http://www.oreilly.com/catalog/oracleian/?CMP=OT16271

By Rick Greenwald,
David C. Kreines

O’Reilly & Associates, Inc.

December 2002

0-596-00336-6, Order Number: 3366

926 pages

$49.95 US
$77.95 CA
#35.50 UK

Buy this book

The goal of Oracle in a Nutshell is to pull together the most essential information on Oracle architecture, syntax, and user interfaces. The content and format of this book, an admirable addition to O’Reilly’s respected In-a-Nutshell line, combine to boil down vital Oracle commands, language constructs, parameters, and file formats in a succinct and highly accessible desktop reference.

Chapter 11: Java and Oracle

The growth in Java usage and popularity has been a key development in the computing world in recent years. Java’s cross-platform capabilities and object-oriented functionality have given it broad acceptance as a development and runtime platform. Since the introduction of Oracle8i, Java has been an integral part of the overall Oracle environment.

There are two basic ways to access Oracle data from Java:


SQLJ

A high-level language designed for embedding SQL statements into Java code. SQL statements used in SQLJ are checked at compile time. Up until Oracle9i, you could use SQLJ only for static SQL statements. With Oracle9i, you can now use SQLJ for both static and dynamic SQL statements.

JDBC

A Java API that typically involves more coding than SQLJ. The SQL statements used in JDBC code are checked at runtime, so it is more loosely typed than SQLJ.

Both of these interfaces are established standards for Java, and each has its own virtues–fewer statements to code with SQLJ, more control with JDBC. To some extent, use of either interface is a matter of personal choice, although Java, with its low-level programming orientation, tends to appeal to developers who are not deterred by the more detailed coding required with JDBC. You can even mix JDBC calls with SQLJ in the same program if you wish.

This chapter focuses on using Java to interface with Oracle databases. It covers the following:


  • Java drivers available for Oracle
  • Using Java within the Oracle database
  • Mapping between Java datatypes and Oracle datatypes
  • SQLJ and JDBC interfaces to Oracle

The use of Java in general is beyond the scope of this book. However, for a very helpful summary of Java capabilities and syntax, we recommend Java in a Nutshell by David Flanagan (O’Reilly). For additional information about SQLJ and JDBC, see Java Programming with Oracle SQLJ by Jason Price and Java Programming with Oracle JDBC by Don Bales, also from O’Reilly. See also the Oracle documentation for these products.

Java Drivers

Oracle supplies two types of JDBC drivers:


  • A JDBC Oracle Call Interface (OCI) driver, or fat driver, which is a Type 2 driver. This driver allows you to use the full capabilities of Oracle Net Services.
  • A JDBC thin driver, a Type 4 driver that is 100% pure Java but does not provide all the capabilities of Oracle Net Services.

Each of these types of drivers has client-side and server-side versions.

Check the Oracle documentation for your version of Oracle for a compatibility listing for these drivers, the Oracle version number, and the supported versions of the JDK and JDBC code.

Recommended for you...

Best Certifications for Database Administrators
Ronnie Payne
Oct 14, 2022
Best Courses for Database Administrators
Ronnie Payne
Jul 22, 2022
TYPE Definition Change in Oracle 21c
Is COUNT(rowid) Faster Than COUNT(*)?
Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.