There are several areas of functionality in the Oracle database that relate, either directly or more peripherally, to using the database in connection with the Internet. For example, you can:
Access an Oracle database through a web server, which is included with the product
Use Internet-era standards, such as the Java programming environment or XML-formatted information
Use a new development tool in Oracle Database 10g to build browser-based applications
Oracle HTTP Server (OHS) is a web server that is included with the Oracle database. The Oracle HTTP Server is essentially the same HTTP server that is included as part of Oracle Application Server. Based on the Apache web server, it has different mods that support different types of functionality.
|
Before Oracle Database 10g, OHS came as an integrated part of the database. Oracle Database 10g includes a standalone version of OHS, which has only some modules (mods)for example, mod_plsql, mod_cgi, mod_perl, and others. (Previous versions of Oracle came with a version of OHS that included a larger number of mods.) The standalone version comes on a separate CD-ROM and is installed separately.
The mod most directly related to the Oracle database is mod_plsql, which provides a connection to the PL/SQL engine within the Oracle database. This module allows a user to call an Oracle PL/SQL procedure in the database.
When a user calls an Oracle procedure, OHS uses two types of configuration information:
A Data Access Descriptor (DAD), which defines the Oracle database and username/password combination used to access the database
Some form of pass-through identifier, which routes the call to a PL/SQL procedure
The connection to the database is established through the DAD, which identifies the target database and either uses a specific username and password combination or prompts the user for a username and password. Each PL/SQL agent is associated with a DAD, and each DAD can be associated with several agents.
OHS is configured to listen on a particular port. Requests come in the form of URLs consisting of the name of the server, the port number of the server, the name of the PL/SQL agent that will service the request, and the name of the stored procedure that is to be executed. For instance, suppose that the server name is homeserver, the PL/SQL agent that is to service the request is netu, and the listener is listening on port 4000. A request for a stored procedure called return_time would look like the following:
http://homeserver:4000/netu/return_time
If this stored procedure accepts parameters, those parameters can be included in the standard URL syntax following the name of the procedure. Of course, this stored procedure would be designed to return HTML code in response to this call.
The Internet era has popularized a new set of standards. The Oracle database provides functionality to support most of these standards, such as the HTTP server mentioned in the previous section. Two standards have a significant amount of supportJava and XML.
The Oracle database includes its own Java Virtual Machine, called the Oracle JVM (formerly known as JServer). Java programs can be developed with any standard Java tool. You can load either the Java source code or the "compiled" version of the Java program in its .class format into the database.
The Oracle JVM runs in the same process space as the standard Oracle database and can directly access the information in the database buffers, which can help to improve the performance of data access through Java. It runs as part of a database session, so there is no need to establish an explicit connection to the Oracle server. Because it's part of the Oracle server, the Oracle JVM uses the same security and authentication methods as its host database.
The Oracle JVM Accelerator included with Oracle is a native code compiler that can deliver performance for Java binaries that's close to the performance of compiled C code. It operates by converting Java binaries into specialized C programs, which are then compiled into native libraries. Oracle claims that the garbage collection process (an integral part of a Java Virtual Machine) implemented in the Oracle JVM also provides better performance than most other Java virtual machines.
Enterprise JavaBeans, or EJBs, are a type of Java program that can be run on a server machine within the context of an EJB transaction server. The EJB transaction server provides system-wide services for all EJBs, such as transaction and state management and communication with other EJB servers. The EJB server implemented by Oracle can use some of the internal management capabilities of the Oracle database server, such as those in the shared server. Oracle includes automated tools to load and publish EJBs, which makes them easier to use with Oracle.
PL/SQL procedures can be called from any Oracle JVM application through the SQLJ interface embedded in the server (the next section describes SQLJ). However, you have to "publish" the top-level Java methods; publishing creates, in effect, a PL/SQL interface for the methods and thus makes them available to PL/SQL procedures. Once the wrapper is created, you can use the Java application just as you would any other PL/SQL procedureeven as part of a standard SQL statement.
With Oracle Database 10g, you can call Java procedures in the database directly, without the need for a PL/SQL wrapper.
|
The JPublisher tool, which comes as a part of Oracle8i and beyond, is used to create the interface between user-defined datatypes and Java wrapper classes. This capability allows you to extend the object-relational datatypes you may have already created with Oracle to the Java environment, or to create user-defined datatypes that can act as persistent storage for the Java objects you use in your Java applications.
Oracle includes two application programming interfaces to data from the Java environment: JDBC and SQLJ. JDBC is a fairly low-level interface that gives Java developers complete control over the interaction between Java applications and data in the Oracle database. JDBC is the functional equivalent of existing APIs such as ODBC. Like ODBC, JDBC is a vendor-independent API.
The JDBC interface is standard, but Oracle offers it in three flavors:
A thin client, 100% Java version
This version is compact (150 KB compressed) and ideal for clients that use only Java.
A slightly fatter client version that is based on the Oracle Call Interface (OCI)
This version requires some form of Oracle networking software that supports OCI.
The in-database JDBC driver (JDBC KPRB)
Java code uses the JDBC KPRB (Kernel Program Bundled) version to access SQL on the same server.
The OCI version of the JDBC interface is a little faster than the pure Java version, so it is most appropriate for use in places like a middle-tier component. The server-side JDBC driver is used for Java stored procedures that run inside the Oracle server.
Oracle also includes the SQLJ interface. SQLJ is a Java library that lets developers use embedded SQL statements in their Java applications. The SQLJ interface works like the Pro* interfaces that already exist for other 3GL languages, such as Pro*C and Pro*COBOL, but unlike these interfaces, SQLJ is an industry standard. You can simply insert SQL statements into your Java code, and the SQLJ translator will translate those calls into their underlying JDBC equivalents.
There are a couple of significant differences between JDBC and SQLJ. Because JDBC simply submits SQL statements as strings, any problems with your SQL syntax won't be found until they are detected by the Oracle database at runtime. With SQLJ, the translator parses the SQL statements and returns errors. On the other hand, SQLJ can be used only for static SQL statements, while JDBC can submit dynamically constructed SQL statements. Much of the flexibility built with dynamic SQL statements can be implemented using bind variables, but there may be times when you need to use the JDBC interface. You can easily mix and match SQLJ and JDBC in your Java application, but the presence of any SQLJ code will require the use of the translator.
XML is a kind of evolutionary standard. It is a text-based markup language, like HTML, but it can be extended to describe a virtually unlimited number of datatypes and structures. Because of this flexibility, it has become a popular standard format for data storage and exchange.
The Oracle database supports a variety of XML standards. It also provides the functionality of a complete XML database, XML DB, as part of the Oracle database. See the later section describing XML DB.
Oracle includes a number of features that support XML, such as its XDK (or XML development kit) for Java, C, C++, and PL/SQL. The XDK lets developers send, receive, and interpret XML data from applications written in their respective languages. From Oracle9i on, the XDK also supports the XML schema standard for defining the datatypes for a particular XML document, which replaces the old method of using Document Type Definitions (DTDs). Since Oracle9i, all versions of the XDK also include two JavaBeans (or components), the DBAccess Bean and the DBView Bean, that make it easier for developers to define access to and view XML data stored in the database.
Oracle9i also provided these XML-related features:
XML class generators for Java and C++
Create classes from XML schema definitions.
XML SQL utility
Supports reading and writing XML data to and from the database using SQL. You can also get most of this functionality by using the DBMS_XMLGEN built-in package.
XSQL servlet
Generates XML documents from one or more SQL queries and uses XSL stylesheets to format the results. This servlet can also be used to insert, update, and delete data using XML.
The Oracle9i release included the new XMLType datatype, which we described in Chapter 4. This datatype allows native storage of XML documents in the Oracle9i and later database versions.
Oracle Database 10g continues the improvement in XML support by adding the ability to use multibyte character sets with XML for internationalization.
XML DB is a term for a group of XML features that were introduced as part of Release 2 of Oracle9i. XML DB consists of four key areas:
XMLType
Described in Chapter 4, the XMLType datatype indicates to the Oracle database that the contents are XML data, so that specific XML operations, such as XPath-based searches and updates, can be performed on it.
Support for XMLSchema
An XMLSchema is a description of the specific contents and types in an XML document, and can be used as a constraint for an XMLType column. Oracle can also use the information contained in an XMLSchema to automatically shred documents into a series of objects and store them in the database with no loss of information. Oracle XML DB is then able to use the information contained in the XMLSchema to optimize XPath-based queries and updates over the content of XML documents stored in the database.
XML DB repository
The XML DB repository allows a URL to be used to locate an XML document, or to define relationships between XML documents stored in the Oracle database. The XML DB repository includes a hierarchical index that allows a URL-based access to be as efficient as a primary-key based access. The repository also includes support for HTTP, FTP, and WebDAV protocols, which are used by many popular applicationsfor example, Windows Explorer, Internet Explorer, Microsoft Office, and XML editors such as Corel's XMetaLto access content stored in the Oracle database without requiring Oracle software on the client.
SQL/XML
SQL/XML provides a standardized method for generating XML documents directly from a SQL statement.
Oracle offers a wide set of development tools, which we described in Chapter 1. Oracle Database 10g includes a new development tool specifically designed to create and run applications in a browser environment, HTML DB.
HTML DB harks back to the days of WebDB, which provided a way to develop HTML-based applications. Like WebDB, HTML DB gives you a series of browser-based wizards that help you create standard application components.
HTML DB uses the concept of a workflow as the organizing principle for sets of these components. The workflow provides a menu interface, typically using tabs, as shown in Figure 14-1.
Within a workflow, you create various pages, which implement specific pieces of functionality, such as reports or data entry or a tree structure used for hierarchical browsing. You can link different pages together within a workflow.
HTML DB lets you provide security for pages and workflows to limit access to HTML DB pages. Workflows and pages have templates that control their look and feel.
Two other aspects of HTML DB provide functionality of interest to DBAs as well as developers:
This portion of the product has a graphical, browser-based interface for all aspects of SQL, from queries to data definition.
This portion of the product gives you the ability to import data from text or from XML or Excel spreadsheets, and to export data directly to text or XML formats.