Files Prepare Run Troubleshooting Related Topics
This example demonstrates how to use cached, filtered, and sorted rowsets. A RowSet is an extension of a Java ResultSet. Like a result set, a rowset is a Java object that holds tabular data. However, a rowset adds significant flexibility to result set features and reduces or eliminates some result set limitations. Cached rowsets are disconnected rowsets. That is, they do not maintain a connection to a database. Instead, they reconnect only when making database changes or when repopulating the database with data.
In this example, a rowset is used to hold patient data to display on a Web page. The user can search for patient records and then sort the results. Using a rowset to hold the data rather than a result set minimizes the number of database round trips required to filter and sort the data, and improves application performance.
This example demonstrates how to:
When you run this example, a Web page opens in a browser. The workflow of the Web pages proceeds as follows:
As you work through the example, the corresponding rowset XML is written to the server window to help you understand what is happening behind the scenes and to demonstrate the printRowSetXML(rs) method.
Directory Location:
BEA_HOME/wlserver_10.3/samples/server/examples/src/examples/jdbc/rowsets
(where BEA_HOME is the directory containing your WebLogic Server installation)
File Click source files to view code. |
Description |
|---|---|
| application.xml | Standard descriptor file for the Enterprise application. |
| build.xml | Ant build script for building and running the example and for recreating database tables, if necessary. |
| Confirmation.jsp | JSP page that displays a confirmation message in your browser after data changes are successfully made to the database. |
| Edit.jsp | JSP page that enables you to edit data in the cached rowset. When submitting changes, the changes are immediately propagated to the database through PatientSessionEJB. In many cases, it is more efficient to synchronize data changes with the database after all changes have been made. In this example, the design was kept simple and data changes are made to the database immediately. |
| Error.jsp | JSP page that displays an error message in your browser if data changes are not successfully made to the database. |
| ExamplesFooter.jsp | Common footer used in JSP pages in this example. |
| ExamplesHeader.jsp | Common header used in JSP pages in this example. |
| Patients.jsp | JSP page that displays a list of patients who match search criteria in your browser. The list is generated from a filtered rowset. |
| PatientSessionEJB.java | EJB that gets the data from the database and stores it as a cached rowset. When data changes are made, this EJB synchronizes the rowset changes with the database. |
| RowSetsServlet.java | Servlet that coordinates the work of the example, including calling the proper JSP pages and setting the sorter and filter on the rowset in PatienSessionEJB. |
| Search.jsp | Starting page in your browser in which you enter search criteria used to filter the data displayed in Patients.jsp. |
| SearchPredicate.java | Implements the javax.sql.rowset.Predicate interface. The example uses this class to create a Predicate object and uses the object to set the filter on the filtered rowset. Specifically, the predicate compares a case-insensitive string to a case-insensitive column value. |
| table.ddl | SQL script files used with the ant db.setup.pointbase command. This script drops and recreates tables in the PointBase demo database that are used in this example. |
| web.xml | Web application deployment descriptor. |
| weblogic-application.xml | WebLogic-specific descriptor file for the Enterprise application. The Enterprise application in this example does not require WebLogic-specific settings in this file. |
| weblogic.xml | WebLogic-specific descriptor file for the Web application. |
Before working with this example:
This example uses tables in the PointBase demo database. The database should already contain the necessary tables and sample data. However, if you need refresh the tables in the demo database, execute the following command from the shell where you set your environment:
ant db.setup.pointbase
This command uses the build.xml and table.ddl files, located in the SAMPLES_HOME\server\examples\src\examples\jdbc\rowsets directory, to drop, recreate, and repopulate tables in the PointBase demo database used by the example.
The example uses JDBC connections from the examples-demoXA JDBC data source in the wl_server domain. You can view the data source configuration in the Administration Console:
If you need to configure the examples-demoXA data source, see Configure JDBC Data Sources for instructions.
To build and deploy the example:
cd SAMPLES_HOME\server\examples\src\examples\jdbc\rowsets
SAMPLES_HOME refers to the main WebLogic Server samples
directory, such as c:\bea\wlserver_10.3\samples.
ant build
clean:
prepare.example:
[mkdir] Created dir: C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar
[mkdir] Created dir: C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\META-INF
[mkdir] Created dir: C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsEjb
[mkdir] Created dir: C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar
[mkdir] Created dir: C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF
[mkdir] Created dir: C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsEjb\examples\jdbc\rowsets
copy.files:
[copy] Copying 2 files to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\META-INF
[copy] Copying 8 files to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar
[copy] Copying 2 files to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF\src\examples\jdbc\rowsets
[copy] Copying 1 file to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF
[copy] Copying 1 file to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF
[copy] Copying 1 file to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF
[copy] Copying 1 file to C:\bea\wlserver_10.3\samples\server\examples\src\examples\jdbc\rowsets\jdbcRowSetsEar\jdbcRowSetsEjb\examples\jdbc\rowsets
build.ear:
[copy] Copying 1 file to C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF\lib
[ejbgen] EJBGen 10.3
[ejbgen] Creating C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb\examples\jdbc\rowsets\PatientSessionHome.java
[ejbgen] Creating C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb\examples\jdbc\rowsets\PatientSession.java
[ejbgen] Creating C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb\\ejb-jar.xml
[ejbgen] Creating C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb\\weblogic-ejb-jar.xml
[ejbgen] Creating C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb\ejbgen-build.xml
[move] Moving 2 files to C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb\META-INF
[javac] Compiling 3 source files to C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsEjb
[javac] Compiling 2 source files to C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar\jdbcRowSetsWar\WEB-INF\classes
[wlappc]
[wlappc]
build:
BUILD SUCCESSFUL
ant deploydeploy: [wldeploy] weblogic.Deployer -noexit -source C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar -adminurl t3://localhost:7001 -user weblogic -password ******** -deploy [wldeploy] weblogic.Deployer invoked with options: -noexit -source C:\bea\wlserver_10.3\samples\server\examples\build\jdbcRowSetsEar -adminurl t3://localhost:7001 -user weblogic -deploy [wldeploy][wldeploy] Task 0 initiated: [Deployer:149026]deploy application jdbcRowSetsEar on examplesServer. [wldeploy] Task 0 completed: [Deployer:149026]deploy application jdbcRowSetsEar on examplesServer. [wldeploy] Target state: deploy completed on Server examplesServer [wldeploy] BUILD SUCCESSFUL
ant run First Name |
Middle Name |
Last Name |
Date of Birth |
SSN |
Phone |
Gender | |
|---|---|---|---|---|---|---|---|
| Fred | I | Winner | 1965-03-26 | 123456789 | fred@golf.com | 4151234564 | Male |
| Larry | J | Parrot | 1959-02-13 | 777777777 | larry@bball.com | 4151234564 | Male |
| Charlie | E | Florida | 1973-10-29 | 444444444 | charlie@star.com | 4151234564 | Male |
| Gabrielle | H | Spiker | 1971-08-17 | 333333333 | volley@ball.com | 4151234564 | Female |
| Page | A | Trout | 1972-02-18 | 888888888 | page@fish.com | 4151234564 | Male |
(Internet connection required.)
Copyright © 1996, 2008, Oracle and/or its affiliates. All Rights Reserved.