Oracle® interMedia User's Guide 10g Release 1 (10.1) Part Number B10840-01 |
|
|
View PDF |
You can develop traditional client/server or two-tier applications, or you can develop multitier applications. Either method can then deploy Web applications to run on an application server tier, be tightly integrated with Oracle Database, and allow users access to the application from their desktop through a Web browser.
Using a complete development framework supported by class library interfaces, you can create production quality interMedia applications for use in a production environment where users can interact with the application through either the standalone client interface or a Web browser. For Web applications, which are based on standards such as TCP/IP, HTTP, HTML, XML, and XTHML, this is all facilitated by rapid developments in the underlying technology. As key software components become more tightly integrated, developers' tasks to design, create, and manage Web applications become faster, easier, and simpler to implement.
Using either the object type interface or the relational interface, interMedia provides Internet support for Oracle Application Server 10g and Oracle Database and authoring tools so you can quickly develop Web-based applications to upload to the database, retrieve from it, and manipulate multimedia data for delivery to Web browsers.
Oracle interMedia supports application development by:
Providing class libraries that allow access (insert, update, and retrieve) and manipulation (process) of multimedia data stored in the database. Class libraries provide access to multimedia data stored in the database in the following ways:
Using Oracle interMedia Java Classes. Using the Java database connectivity (JDBC) interface, you can quickly develop applications for use on any tier (client, application server, or database) to manipulate and modify audio, image, and video data, or heterogeneous media data stored in a database. Oracle interMedia Java Classes makes it possible for JDBC result sets to include both traditional relational data with interMedia columns of object type media data, to easily select and operate on the result set, to access object attributes, and to invoke object methods. See Oracle interMedia Java Classes Reference for more information.
Using Oracle interMedia Java Classes for servlets and JavaServer Pages (JSP). These additional classes support Web technologies. See Section 1.10.3 for more general information and Section 2.2 for more information about developing Java-based Web applications using JDBC. See Section 3.1.2 for a description of a Java servlet application and Section 3.1.3 for a description of a JSP application that uses these classes. See Oracle interMedia Java Classes Reference for more information.
Using the interMedia/BC4J integration package, which includes the interMedia domain classes and a set of utilities. These classes are for use with Oracle JDeveloper 10g, the Java integrated development environment (IDE) tool that supports the application framework (Oracle Business Components for Java (BC4J)) that enables you to build multitier, component-based Internet applications. See Section 1.10.3 and Oracle JDeveloper 10g help for more information.
Using Oracle interMedia Custom DataSource and DataSink classes. These classes are an extension to JMF version 2.0/2.1 that allows a JMF application to upload and retrieve time-based media data stored in a database using interMedia OrdAudio and OrdVideo object types. See Section 1.10.4 and Oracle interMedia Java Classes Reference for more information.
Using Java Advanced Imaging (JAI) classes. Oracle interMedia Java Classes describes three types of stream objects, which provide interfaces to BLOB and BFILE data, that can be used by JAI. These classes allow a JAI application to read and write image data stored in a database using interMedia OrdImage objects, or in BLOBs or BFILEs. See Oracle interMedia Java Classes Reference for more information.
Using C++ and traditional 3GLs through modern class library interfaces.
Using the PL/SQL Gateway (mod_plsql) feature of the Oracle HTTP Server and the PL/SQL Web Toolkit features of Oracle Application Server 10g and Oracle Database, to listen for browser requests, to execute stored PL/SQL procedures in the database using Oracle Net and Oracle Call Interface (OCI), and to generate an HTML page containing data and code for the response returned to the Web browser for display. As a Web application developer, you can write PL/SQL servlets and PL/SQL server pages (PSP) that invoke PL/SQL procedures stored in the database through an Oracle Net connection and OCI. See Section 2.1 for more information.
Integrating Oracle development tools with tightly integrated components to enable you to quickly and easily develop applications that provide access to (insert, update, and retrieve) and manipulation (process) of multimedia data stored in the database for delivery to Web browsers and client applications. These development tools include:
Oracle Application Server Portal -- a simple browser-based environment for building and deploying enterprise information portlets (EIPs). An enterprise portal provides access to portlets, which are summarized versions of applications and Web content situated in defined regions of the Web page. Oracle Application Server Portal portlets execute PL/SQL stored procedures residing in the database, which in turn generate an HTTP response in the form of a generated HTML page. Oracle Application Server Portal contains two predefined components: Oracle Application Server Forms Services and Oracle Application Server Reports Services, which both support rich media content being uploaded or downloaded between the database and the portal framework form or report. See Section 1.10.3 for more information.
Oracle JDeveloper 10g -- written 100% in Java, is the IDE tool that supports the application framework (Oracle Business Components for Java (BC4J)). An interMedia/BC4J integration package includes the interMedia domain classes and a set of utilities. The domain classes are wrappers of Oracle interMedia Java Classes and inherit all the underlying multimedia retrieval, upload, and manipulation methods. The domain classes support the BC4J framework APIs and provide built-in integrated multimedia capabilities, while the utility classes support the retrieval, rendering, and uploading of multimedia content. See Section 1.10.3 for more information.
Oracle Designer -- a tool used to manage software configuration management for controlling the evolution of an application from identification of components, through initiation, evaluation, authorization, development, and implementation. Oracle Designer can generate C++ classes that enable applications running on the client or on Oracle Application Server 10g or on Oracle Database to call interMedia methods.
Oracle Content Management SDK -- lets you create custom file system applications using XML and Java that use the features and capabilities of the database, and a variety of Web-based interfaces, such as Java servlets and JSP or executing SQL or calling stored PL/SQL procedures for execution in the transaction context of the database.
Integration with third-party client Web authoring tools for rapid Web site development to allow direct delivery of dynamic multimedia data stored in the database to the Web site. These third-party Web authoring tools include:
Oracle interMedia Plug-in for RealNetworks servers -- Oracle interMedia Plug-in for RealNetworks, RealSystem RealServer 7.0, RealSystem iQ Server 8.0, and Helix Universal Server. This tool lets these RealNetworks servers stream multimedia data to a client directly out of the database. This plug-in is installed in the RealNetworks server and defined in the RealNetworks server configuration file. The data is requested with a URL, which contains information necessary to select the multimedia data from the database. See Section 1.10.2 for more information.
Chapter 3 describes the interMedia photo album Web application and how to develop media upload and retrieval applications using either the PL/SQL development environment, the Java IDE, or the Microsoft Active Server Pages (ASP)/Visual Basic (VB) development environment for developing Web applications for the Microsoft IIS Web Server using interMedia. In addition, this chapter describes an interMedia Code Wizard application that lets you create PL/SQL stored procedures for the PL/SQL Gateway to upload and retrieve media data (images, audio, video, and general media) stored in a database using interMedia object types. You can either create and compile standalone media access procedures using the Code Wizard, or you can create the source of media access procedures for inclusion in a PL/SQL package.
Chapter 4 describes the IMExample Java sample application (sometimes referred to as a demo) and how the classes of Oracle interMedia Java Classes are used to create this sample application that lets you retrieve from the sample schema, save to a file, play, and delete from the sample schema interMedia image, audio, video, and testimonial data using the respective interMedia object types, OrdImage, OrdAudio, OrdVideo, and OrdDoc.
If you are not familiar with developing PL/SQL Web applications and using the PL/SQL Gateway and PL/SQL Web Toolkit, see Section 2.1.
If you are not familiar with developing Java-based Web applications using JDBC to access interMedia objects, see Section 2.2.
SQL developers familiar with the database can develop Web applications that exclusively use Oracle Application Server 10g and Oracle Database using the PL/SQL development environment. PL/SQL is a completely portable, high-performance transaction processing language that combines the data manipulation power of SQL with the data processing power of procedural languages.
The PL/SQL development environment lets you achieve the best performance for database-intensive applications because PL/SQL is highly optimized for use with the database through its support for and tight integration with SQL, support for processing an entire block of SQL statements at one time, and letting you compile PL/SQL procedures and store them in executable form in the database, to be called later. In addition, as a development environment, SQL developers have support for the object-oriented programming model, can experience higher productivity due to its procedural nature, and can come quickly up to speed to develop PL/SQL-based Web applications.
Developing Web applications using PL/SQL consists of developing one or more PL/SQL packages consisting of sets of stored procedures that interact with Web browsers through HTTP. Stored procedures can be executed in several ways:
From a hypertext link that calls a stored procedure when it is selected.
By clicking Submit on an HTML form to denote the completion of a task such as filling out a form supplied on the HTML page.
By passing parameters to a stored procedure based on user choices from a list.
Information in the stored procedure, such as tagged HTML text, is displayed in the Web browser as a Web page. These dynamic Web pages are generated by the database and are based on the database contents and the input parameters passed in to the stored procedure. Using PL/SQL stored procedures is especially efficient and powerful for generating dynamic Web page content.
There are two ways of generating HTML output from PL/SQL:
Using function calls to generate each HTML tag for output using the PL/SQL Web Toolkit package that is part of Oracle Application Server 10g and Oracle Database and whose owa
packages are loaded into a common schema so that all users can access it.
Embedding PL/SQL code in Web pages (PL/SQL server pages)
Use interMedia when media data such as images, audio, video, or combinations of all three are to be uploaded into and retrieved from database tables using the interMedia object types and their respective sets of methods.
Media upload procedures first perform a SQL INSERT operation to insert a row of data in the media table, which also initializes instances of the respective interMedia object columns with an empty BLOB. Next, a SQL SELECT FOR UPDATE operation selects the object columns for update. Finally a SQL UPDATE operation updates the media objects in their respective columns. interMedia methods are called to do the following:
Initialize the object columns with an empty BLOB.
Set attributes to indicate media data is stored internally in a BLOB.
Get values of the object attributes and store them in the object attributes.
When exceptions occur, determine the length of the BLOB content and its MIME type.
Media retrieval operations involve the following tasks:
Retrieving the object from the database into a local object.
Checking the cache validity of the object based on its updated time versus that of the HTTP header time.
Determining where the media object is located: in the database, in a BFILE, or at a URL location; then, getting the media, and downloading it for display on an HTML page.
interMedia methods are called to get the time that the media object was last updated, to determine if the media is stored locally in the database, in a BFILE, or at a URL location, to get the MIME type of the media object, and finally to retrieve the media data.
Oracle Application Server 10g and Oracle Database install Oracle HTTP Server powered by the Apache HTTPD server that contains the PL/SQL Gateway to communicate directly with a client Web browser.
Oracle HTTP Server serves mainly the static HTML files, images, and so forth, that a Web application uses, and is usually located in the file system where Oracle HTTP Server is installed. Oracle HTTP Server contains modules or plug-ins that extend its functions. One of these modules supplied by Oracle is the mod_plsql module, also known as the PL/SQL Gateway. The PL/SQL Gateway serves data dynamically from the database to Web browsers by calling PL/SQL stored procedures. The PL/SQL Gateway receives requests from a Web browser in the form of PL/SQL servlets or PL/SQL server pages that are mapped to PL/SQL stored procedure calls. PL/SQL stored procedures retrieve data from the database and generate an HTTP response containing the data and code from the PL/SQL Web Toolkit to display the generated Web page in a Web browser. The PL/SQL Web Toolkit contains a set of packages called htp
, htf
, and owa
packages that can be used in the stored procedures to get information about the request, construct HTML tags, and return header information to the client Web browser.
Figure 2-1 shows these main components of the PL/SQL development environment, Oracle HTTP Server (a component of Oracle Application Server 10g and Oracle Database), the Web browser, and the database. The following information describes how a client Web browser request is turned into a Web page response from the execution of the PL/SQL procedure:
A client Web browser sends a PL/SQL server page or servlet request to Oracle HTTP Server.
Oracle HTTP Server routes the request to the PL/SQL Gateway (mod_plsql).
The PL/SQL Gateway forwards the request to the database using configuration information stored in the database access descriptor (DAD) and connects to the database.
The PL/SQL Gateway prepares the call parameters and invokes the PL/SQL package and the PL/SQL stored procedure in the application.
The PL/SQL procedure generates an HTML page using data from the database and special packages in the PL/SQL Web Toolkit accessed from the database. The PL/SQL Web Toolkit contains a set of packages called htp
, htf
, and owa
packages that are used in the stored procedures to get information about the request, construct HTML tags, and return header information back to the client Web browser as the response returned to the PL/SQL Gateway.
The PL/SQL Gateway sends the response to Oracle HTTP Server.
Oracle HTTP Server sends the response to the client Web browser for display as a formatted Web page.
Figure 2-1 Components of the PL/SQL Development Environment
Usually, the returned formatted Web page has one or more additional links, and each link, when selected, sends another request to the database through the PL/SQL Gateway to execute one or more stored procedures. The generated response displays data on the client Web page usually with additional links, which, when selected, execute more stored procedures that return the generated response for display as yet another formatted Web page, and so forth. This is how the PL/SQL application in the PL/SQL development environment is designed to work.
Web application developers who use the PL/SQL development environment, create a PL/SQL package specification and body that describe procedures and functions that comprise the application. The package specification defines the procedures and functions used by the application, and the package body is the implementation of each procedure and function. All packages are compiled and stored in the database to perform specific operations for accessing data in the database and formatting HTML output for Web page presentation. To invoke these stored PL/SQL procedures, Web application developers use the request/response PL/SQL servlets and PL/SQL server pages (PSP) to allow Web browser clients to send requests and get back responses using HTTP.
Oracle HTTP Server maps a URL entered in a browser to a specific PL/SQL procedure stored in the database. It does this by storing specific configuration information by means of a DAD for each stored procedure. Thus, each DAD contains the database connection information that is needed by the Web server to translate the URL entered into a database connection in order to call the stored procedure.
Oracle HTTP Server listens for a request, routes the request to the PL/SQL Gateway, which forwards it to the database. Configuration information values stored in a DAD determine the database alias to use, the connection string to use for remote access, the procedure to use for uploading or downloading documents, and the user name and password information to allow access to the database. From the Web browser, the user specifies the URL that invokes the PL/SQL Gateway. The URL has a defined format specifying all required and optional parameters needed including the location of the DAD and the name of the PL/SQL stored procedure to run, as shown in Example 2-1.
Example 2-1 URL Format Required for Invoking mod_plsql in a Web Browser
protocol://hostname[:port number]/DAD-name/[[!][schema name.][package name.]procedure_name[?query_string]]
For a detailed description of each parameter and options available, see Oracle HTTP Server mod_plsql User's Guide. However, for the purpose of using the photo album application for interMedia and the PL/SQL Web Toolkit described in Section 3.1.1, the URL can be simplified to the format shown in Example 2-2.
Example 2-2 URL Format Required to Invoke mod_plsql in a Web Browser for the Photo Album Application
protocol://<hostname>[:<port-number>]/DAD-name/]procedure_name
When the URL is entered in the Web browser, it includes the protocol (HTTP or HTTPS), the name of the hosting Web server, and the port number to which it is listening to handle requests. Next, the specified virtual path includes /pls/<DAD-name>
to indicate that the Web server is configured to invoke mod_plsql, and the location of the DAD on the Web server.
In Example 2-1, the last five parameters include the exclamation point (!) character, schema name, package name, procedure name, and query string. From the syntax, the exclamation point, schema name, package name, and query string parameters are optional; only the procedure name is required.
The exclamation point indicates that flexible parameter passing is being used. The schema name, if omitted, is resolved based on the user name. The package name, if omitted, means the procedure is standalone. The query string parameters are for the stored procedure and follow a special format. Of these five parameters, the procedure name must be specified in both the DAD and the URL. The other four parameters are specified in either the DAD or the URL, or not at all, depending on the application.
The URL displays the home page for the specified DAD. When the URL is entered in the address field of the Web browser page, it invokes either the specified DAD location only, or the specified DAD location along with the procedure name, or the specified DAD location along with the schema.package.procedure
name. The response is returned as an HTML page. The HTML page contains the requested data and any other specified code for display in the client's Web browser. The Code Wizard described in Section 3.2.1 illustrates how this works. For example, to invoke the Code Wizard administration URL, enter the following URL shown in Step 3 in Section 3.2.2:
http://<hostname>:<port-number>/pls/ordcwadmin
The virtual path includes pls
to indicate that the Web server is configured to invoke mod_plsql, followed by the name of the DAD used for the Code Wizard administrator, ordcwadmin
.
When the HTML page is displayed, it resolves to the following URL for the Code Wizard administrator:
http://<hostname>:<port-number>/pls/ordcwadmin/ORDCWPKG.menu
ORDCWPKG.menu
represents the package.procedure
name, which is specified as the default home page in the ordcwadmin
DAD.
When the PL/SQL Gateway is invoked, it uses the stateless model and does not allow a transaction to span across multiple HTTP requests. In this stateless model, applications typically can create a session to maintain state by using one of the following techniques: HTTP cookies, a hidden HTML field as an HTML form element of the HTML Form package, or storage of vital information in database tables for query. For more information, see Oracle Database Application Developer's Guide - Fundamentals.
Java database connectivity (JDBC) is a standard Java interface defined by Sun Microsystems, based on the X/Open SQL Call Level Interface that complies with the SQL 92 Entry Level standard, that is used for connecting from Java to relational databases. JDBC supports dynamic SQL, letting a calling program construct SQL statements dynamically at runtime. These are the major benefits of using this Java interface in addition to allowing individual providers, such as Oracle Corporation, to implement and extend their own JDBC drivers.
A database-embedded JVM supports the JDBC interface. Java source code (.java file) is compiled into one or more byte code files (.class
files) and these class files are interpreted at runtime and executed by the embedded JVM. If your Java application uses objects defined in other packages, you must set the CLASSPATH environment variable and specify the paths to all objects used by your application.
Resulting class files for servlets are usually placed in the directory enabled to run servlets. Class files for JSP are usually placed in the JavaBean directory for your servlet's container, while the JSP files are usually copied to a directory enabled to serve JSP, which by default, is your JSP sample application directory. For servlets, the actual location of your servlet class files depends on the servlet container you are using and how it is configured. For JSP, the actual location of your servlet and JSP files depends on the servlet container and JSP engine you are using, and how the engine is configured. Each of the Java sample applications uses the default location of the servlet containers as required by Oracle HTTP Server powered by Apache for an installation of Oracle Application Server 10g or Oracle Database. See the respective Java sample application readme.txt
files for more information.
To write a Java application that uses the JDBC interface and the embedded JVM, perform the following operations that will access interMedia objects in a database table:
Establish a JDBC connection from the Java application to the database.
Call a getConnection( ) method to obtain an OracleConnection object.
If your application will modify the interMedia object, perform the following operations:
Call the setAutoCommit( ) method to disable auto-commit mode.
Execute a SELECT... FOR UPDATE statement on the database table.
Create an OracleStatement or OraclePreparedStatement object in your application. Call the executeQuery( ) method to execute the SELECT... FOR UPDATE statement and return an OracleResultSet object, and fetch a row from the result set.
If your application will not modify the interMedia object, execute a SELECT statement on the database table.
Retrieve the interMedia object from the result set as an instance of one of the classes of Oracle interMedia Java Classes.
Perform operations on the Java application object.
Having retrieved the interMedia Java object from the result set, your application can now load new data into the object, or your application can retrieve or manipulate existing data in the object.
If the interMedia object has been modified by the application, update the database object to include the results of the operations, and commit your changes.
If the application modified the object in the previous step, create an OraclePreparedStatement object that contains a SQL statement that updates the database object, and execute the statement.
Commit the transaction by calling the commit( ) method.
Close the connection to the database table.
The IMExample Java sample application, which is described in Chapter 4, provides examples of each step in this process.
For more information on using JDBC, see Oracle Database JDBC Developer's Guide and Reference.