Read an Excerpt
Chapter 1: Performance and Java EnhancementsThis chapter introduces you to several of the new features in Oracle8i related to performance and Java enhancements that are tested on the Oracle8i: New Features for Administrators Upgrade exam. The areas we will discuss are as follows:
- Java in the database
- Optimizer and query improvements
- Summary management
Java in the DatabaseIn this section, you will cover the following new features resulting from the incorporation of Java in the Oracle8i database:
- Describing Oracle Java components
- Describing )Server installation
- Tuning )Server
Describing Oracle Java ComponentsYou probably already know about the prevalence of Java for use in cross-platform development and on the Internet. Developed by Sun Microsystems, the Java programming language offers platform independence via virtual machine architecture, allowing developers a "write once, use everywhere" approach to code design essential in a Web-enabled marketplace. As a programming language, Java offers many automated storage management features (including garbage collection) that simplify the coding process as well.
If you've ever written C code, you'll find that Java code looks a bit familiar. Programmers proficient in the everpopular C programming language adapt to Java quickly because of its structural similarity to C. Although Java offers many differences from C, programmers often cite use of strongly typed variables in Java as the feature to pay the most attention to. Since many C programmers are used to weak typing, the use of strong typing in Java causes those programmers to pay particular attention to type definition along with regular variable declaration. For the record, PL/SQL also uses strongly typed variable declaration.
Java Features at a GlanceHere is a laundry list of features cited by Java developers as features of the programming language to know for the OCP exam:
- Java is simple to use, once you master the concepts of OO programming.
- The same compiled Java program can run on many different machines through the use of the Java virtual machine.
- Automatic storage management relieves you from explicitly allocating and deallocating memory for variables in your program.
- Java is a strongly typed programming language, so there's little chance of data conversion problems when passing data between Java programs and PL/SQL programs.
- Java doesn't allow pointers. Objects are referenced by name, not by value, so no need to worry about data corruption or memory leaks.
- Like PL/SQL, Java uses exception handling for error management, which greatly simplifies the resolution of errors in the Java program.
- Java applications can be distributed across multiple systems because of its use of the class hierarchy. Names of objects are easily resolved using the flexible namespace feature in a way similar to the way Web site names are resolved on the Internet.
- Security can be made tight both for data in a Java application through the restriction of visibility for attributes and for the program itself to ensure that the Java binary hasn't been altered.
- Java supports multithreading in your application, which offers tremendous application scalability for vast user audiences.
- Java can communicate with Oracle8i data in a standardized way using JDBC and SQLJ drivers.
A Primer on Java ProgrammingChances are, as the DBA you won't necessarily get much opportunity to write Java code. But, you're probably interested in gaining at least a conceptual understanding of how to program in Java. Java is an object-oriented programming language (object-oriented is often abbreviated as OO), and as such, Java supports the notion of a class. Classes are to Java what tables and program units are to Oracle-but instead of existing separately, OO programming uses the class paradigm to marry data and process together.
Think of a conventional example-an employee application. If you're used to the RDBMS mentality, this application probably evokes images of tables called EMP and DEPT for storing employee and department data, respectively. The application probably also consists of some PL/SQL routines for manipulating the data. If you, say, want to manipulate data in the EMP table, you have to either issue some SQL using EMP or write a PL/SQL program that uses EMP. In either case, your code exists as something separate from the EMP table that you have to know about.
Thinking about the employee application from the OO perspective requires you to marry employee data and manipulation processes together into one logical unit called the
employee class. This class defines the relevant fields of employee data to store, which we call attributes in OO parlance. Attributes are like columns in a table. The class identifies the name of the attribute as well as its datatype. However, the class also defines some rules of visibility for attributes in the class. Fields in Java can have static access, meaning that the field is globally available to every instance of that class. Alternately, fields in Java can be defined at the instance level using public, private, protected, or default access. With this emphasis on visibility at a low level, you can enforce better security in OO applications at the object level than you can in relational applications at the table level. To get the same kind of rowlevel security in relational database programming, you have to use fine-grained access control, which we'll discuss later in the book. The class also defines some processes for manipulating data-perhaps a routine for randomly generating a unique employee ID number, for example. These processes for manipulating the attributes are called methods by OO developers, and they are also stored in the class. Methods in a class often manipulate attributes of the class, and the rules of visibility can be controlled further by only showing data from the class via methods of that class to prevent misuse of the object....