Oracle® Database Lite Developer's Guide
Part No. B15920-01
This document enables you to create, deploy, and use a BC4J application, using a tutorial. Topics include:
The Oracle BC4J (Business Components for Java) is a part of the Oracle JDeveloper IDE (Integrated Development Environment), and provides Java developers with tools to create and manage reusable Java components.
BC4J offers a standards-based, server-side Java and XML framework for developers. You can build and deploy reusable business components for high performance Internet applications, such as e-commerce and business-to-business systems. Applications, which are created using BC4J, comprise five basic framework components: Entity Objects, Associations, View Objects, View Links, and Application Modules. Each of these components is interrelated to the other components, which enables you to establish views into database tables. You can combine, filter, and sort data as needed.
When used in application development, BC4J automatically generates database oriented components, so that you can focus on the business logic instead of on database related components.
The sample BC4J application used in this tutorial maintains employee details and stores all items in a relational database.
Before you start developing business components in Java, ensure that the computer you are using for your development meets the requirements specified in this section. Table 20-1 lists configuration and installation requirements for the development computer.
Table 20-1 Development Computer Requirements
|Windows NT/2000/XP User Login||The Windows NT/2000/XP login user must have Administrator privileges on the development computer.|
|Installed Java Components||Java Development Kit 1.4.2 or higher.|
|Installed Oracle Components||Mobile Server or Mobile Development Kit (Oracle Database Lite CD-ROM)
Oracle 8.1.7 or higher
Oracle9i JDeveloper, Release 9.0.3.
Note:The BC4J tutorial is shipped with the Mobile Development Kit as a JAR file named
This section enables you to develop the BC4J application for Oracle Database Lite in phases.
To develop the BC4J application, you must perform the following tasks.
For developing an application using BC4J, you must create two database connections, as follows:
A connection to the back-end Oracle database that is used only within BC4J to test the application while developing within BC4J.
The permanent connection used between the back-end Oracle database and the Oracle Database Lite, which is used by the application after deployment for synchronization between the two databases.
During development and testing within BC4J, use the first connection. After you are done developing the application and are ready to deploy it, change the connection from to the second connection before deploying the application.
The following sections provide details on how to create each type of connection:
You need to create a connection to the back-end Oracle database, which is used only within BC4J to test the application while developing within BC4J. For this example, we create the
tutorialConn connection to connect to the back-end Oracle database using the
oracle.jdbc.driver.OracleDriver for the BC4J development process.
To create the
tutorialConn connection, perform the following steps.
In the JDeveloper System Navigator panel and as displayed in Figure 20-1, right-click the Connections node and choose the New Database Connection option.
Figure 20-1 Choosing a New Database Connection
The Connection Wizard Welcome panel appears, which is displayed in Figure 20-2. Click Next.
Figure 20-2 Welcome Panel - Connection Wizard
The Connection Wizard - Step 1 of 4: Type panel appears, as displayed in Figure 20-3. Create a connection named
tutorialConn and choose
Oracle (JDBC) from the Connection Type list. Click Next.
Figure 20-3 Connection Wizard - Step 1 of 4: Type
The Connection Wizard - Step 2 of 4: Authentication panel appears, as displayed in Figure 20-4. Enter
scott as the user name and
tiger as the password. Select the Deploy Password box. Click Next.
Figure 20-4 Connection Wizard - Step 2 of 4: Authentication Panel
The Connection Wizard - Step 3 of 4: Connection panel appears, as displayed in Figure 20-5. Choose the
thin option from the Driver list and enter your PC Host Name, JDBC Port number, and the database SID in the corresponding fields. Do not select the Enter Custom JDBC URL box. Click Next.
Figure 20-5 Connection Wizard - Step 3 of 4: Connection Panel
The Connection Wizard - Step 4 of 4: Test panel appears, as displayed in Figure 20-6. Click Test Connection. The Connection Wizard displays a connection status message. Click Finish.
Figure 20-6 Connection Wizard - Step 4 of 4: Test Panel
You have finished creating the
tutorialConn, as displayed in Figure 20-7.
Figure 20-7 Connection Wizard - Finish Panel
In JDeveloper, the
tutorialConn icon appears in the System Navigator window under the Connections node, as displayed in Figure 20-8.
Figure 20-8 Tutorial Connection Icon in the System Navigator
In summary, Table 20-2 shows the values that you provide for this connection in the Connection Wizard.
Create the permanent connection used by the application between the back-end Oracle database and the Oracle Database Lite. This connection is used after the application is deployed for synchronization between the two databases—the back-end Oracle database and the local Oracle Lite database.
For this example, create the
WTGJdbc connection, which uses the
Note:Once development is complete for the application, make sure that you modify your application to use the
To create the
WTGJdbc connection, do the following:
Configure the project settings and include the Oracle Database Lite user library named
webtogo.jar. Start JDeveloper and click the Project menu. As displayed in Figure 20-9, select the Default Project Settings option. Then select Development->Configuration->Libraries in the left side pane. Click New Button.
Figure 20-9 Choosing Default Project Settings
In the Project Settings panel, add a new library and name the new library as
webtogo. Enter the
CLASSPATH as given below and displayed in Figure 20-10. Click OK.
Figure 20-10 Adding a New Library and Classpath
webtogo library from the Available Libraries list to the Selected Libraries list, as displayed in Figure 20-11. Click OK.
Figure 20-11 Moving the Webtogo Library to the Selected Libraries List
After configuring project settings as mentioned in this step, create the
WTGJdbc connection using the same method that you used to create
To create the
WTGJdbc connection, start JDeveloper and right-click the Connection object and choose New Database Connection Option. As displayed in Figure 20-12, the Connection Wizard - Step 1 of 4: Type panel appears. Enter
WTGJdbc as the Connection Name and choose
Third Party JDBC Driver as the JDBC Connection Type. Click Next.
Figure 20-12 Connection Wizard - Step 1 of 4: Type Panel
The Connection Wizard - Step 2 of 4: Authentication panel appears, as displayed in Figure 20-13. Do not enter any values in this panel. Click Next.
Figure 20-13 Connection Wizard - Step 2 of 4: Authentication Panel
The Connection Wizard - Step 3 of 4: Connection panel appears, as displayed in Figure 20-14. Click New.
Figure 20-14 Connection Wizard - Step 3 of 4: Connection Panel
The Register JDBC Driver dialog appears, as Figure 20-15 displays. Enter
oracle.lite.web.WTGJdbcDriver as the Driver Class. Choose
webtogo from the Library list and click OK. Enter the following URL.
Figure 20-15 JDBC Driver Dialog
The Connection Wizard - Step 4 of 4: Test panel appears, as Figure 20-16 displays. To test your
WTGJdbc connection, click Test Connection. The Status box displays that the
WTGJdbc connection has been created successfully. Click Finish.
Figure 20-16 Connection Wizard - Step 4 of 4: Test Panel
In summary, Table 20-3 describes the values that are entered in the Connection Wizard to create the
Table 20-3 WTGJdbc Connection - Connection Wizard Description
|Select a JDBC Driver||Third Party JDBC Driver|
Using JDeveloper, create the BC4J component named
tutorialapp, as follows:
In JDeveloper, select New from the File menu. In the New dialog box that appears, the options—Projects in the left panel under General Categories and Empty Project in the right panel are pre-selected as defaults. Select Workspace to enable the OK button and click OK. JDeveloper creates a new empty project named
tutorialapp.jpr, which creates a new project by that name. Select the project and then select File->Rename.
tutorialapp.jpr in the JDeveloper workspace. Select New Business Components Package. As shown in Figure 20-17, the "Business Components Package Wizard, Welcome" dialog appears. Click Next.
Figure 20-17 The Business Components Package Wizard, Welcome Dialog
The "Business Components Package Wizard, Step 1 of 3: Package Name" dialog appears, as illustrated in Figure 20-18. In the Package Name field, enter
tutapp. Click Next.
Figure 20-18 Business Components Package Wizard Step 1 of 3: Package Name
The "Business Components Package Wizard, Step 2 of 3: Connection" dialog appears, as depicted in Figure 20-19.
Figure 20-19 Business Components Package Wizard Step 2 of 3: Connection
Select the values that are listed in Table 20-4 and click Next.
In the "Business Components Project Wizard, Step 3 of 3: Business Components" dialog, select
EMP from the list displayed in the left panel and move it to the "Selected" list, as illustrated by the example in Figure 20-20. Click Finish.
Figure 20-20 Business Components Package Wizard, Step 3 of 3: Business Components Dialog
JDeveloper creates the
TutorialAppModule BC4J component.
After you have completed developing and testing your application, switch the connection to use the
WTGJdbc connection, which is the connection between the Oracle database and Oracle Database Lite. To configure the BC4J component to use the
WTGJdbc connection, perform the following steps.
Right-click on the
TutorialAppModule and click the Configurations... option. The Configuration Manager appears.
In the Oracle Business Component Configuration dialog, click Edit. Choose
WTGJdbc as the JDBC connection.
Click OK. The BC4J component is now configured to use the
Click OK in the Configuration Manager window.
To build and deploy the BC4J component as a simple archive, perform the following steps.
tutorialapp.jpr file and select the Create Business Components Deployment Profiles option. The Business Component Deployment Wizard appears.
Select the Simple Archive Files option from the list displayed and move it to the Selected list. Click Next. By default, this option is already selected.
The "Business Component Deployment Wizard Step 2 of 2: Simple Archive Files" appears. Under the 'Selected Platform - Simple Archive Files' section, accept the default Profile name.
Click Next. Click Finish. The
tutorialapp.bcdeploy file is created under
Right-click the file
tutorialapp.bcdeploy and select Deploy. JDeveloper creates two jar files—
Note:To check the location of the
To write the JSP application that will access the BC4J component, perform the following steps.
In JDeveloper, select File->New Options. Select Empty Project in the right-hand pane. Click OK. The system automatically creates a new empty project called
Under the File menu, select Rename... and rename
tutorialclientapp.jpr file in the JDeveloper workspace. Select File->New. Click Web Tier and select JSP for Business Components. Click OK. The Business Components JSP Application Wizard appears. Click Next.
Figure 20-21 Business Components JSP Application Wizard - Welcome Dialog
Click New. The 'Business Components JSP Application Wizard' appears. Click Next. The wizard displays the 'Business Components JSP Application Wizard - Step 1 of 3:Data Definition' dialog.
Figure 20-22 Business Components JSP Application Wizard - Step 1 of 3: Data Definition Dialog
Click New in the 'Business Components JSP Application Wizard - Step 1 of 3:Data Definition' dialog. The 'BC4J Client Data Model Definition Wizard' appears. Click Next.
Figure 20-23 BC4J Client Data Model Definition Wizard - Welcome Dialog
The 'BC4J Client Data Model Definition Wizard: Step 1 of 2: Definition' appears.
Figure 20-24 BC4J Client Data Model Definition Wizard, Step 1 of 2: Definition Dialog
Verify the default values and click Next.
TutappModule appears as the default definition name in the 'BC4J Client Data Model Definition Wizard - Step 2 of 2: Definition Name' dialog. Click Next.
Click Finish. The 'Business Components JSP Application Wizard' dialog appears. Click Next.
In the 'Business Components JSP Application Wizard - Step 1 of 3: Data Definition' dialog, select
TutappModule as the data model definition, as displayed in Figure 20-25. Click Next.
Figure 20-25 Business Components JSP Application Wizard - Step 1 of 3: Data Definition Dialog
Accept the default selections and click Next in the two dialog boxes that appear: 'Business Components JSP Application Wizard - Step 2 of 3: View Object Forms' and 'Business Components JSP Application Wizard - Step 3 of 3: View Link Form'. The 'Summary' window appears. Click Finish.
To deploy the JSP application as a simple archive, perform the following steps.
In JDeveloper, click the
tutorialclientapp.jpr file and select the file named
tutappclient_jpr_war.deploy. Right click on the
Select 'Deploy to WAR file'. The file
tutappclient_jpr_war.war is created. To track the deployment location, check the 'Deployment Log' text area in JDeveloper.
To package the JSP application, perform the following steps.
Create a sub-directory called
bc4jtutapp under the following location:
tutappclient_jpr_war.war file into the
Edit all the JSP files to delete the following.
as shown below:
<%@page language="Java"errorpage="errorpage.jsp" ContentType="text/html;charset=windows-1252"%>\
web.xml file and insert the following tag at the end just before closing
<filter> <filter-name>CheckSessionFilter</filter-name> <filter-class>oracle.lite.web.CheckSessionFilter</filter-class> </filter> <filter-mapping> <filter-name>CheckSessionFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Using the Command Prompt window, run the Packaging Wizard and provide the screen inputs that are listed and described in Table 20-5.
Table 20-5 Packaging Wizard Input Details
|Application||Application Name||BC4J Oracle Database Lite Tutorial Application|
|Application||Description||Oracle Lite Tutorial Application|
|Application||Application Classpath||no input|
|Application||Local Application Directory||<
|Files||The Packaging Wizard loads all files in a directory under the Local Application Directory.||N/A|
Table 20-6 lists the servlet names and their corresponding classes that are created in the Packaging Wizard by default.
Table 20-6 Servlet Names and Classes
|Screen||Servlet Name||Servlet Class|
Table 20-7 lists server side and client side database values that you must specify in the Packaging Wizard.
Under the Snapshots section, click Import. You can now connect to the Oracle Database by providing the following values in the "Connect to Database" dialog.
Table 20-8 lists values that you must specify in the Connect to Database dialog.
After specifying the Database Connection values, select
Emp from the list of tables.
Click Edit and change the weight from 0 to 1.
Retain the default values for Roles, Sequences, DDLs, and Registry fields.
Package the application into a JAR file.
To configure the JSP application from the Mobile Manager, perform the following steps.
Using the Command Prompt window, enter
runmobileserver to start the Mobile Server.
Using the following URL, browse the local host.
Note:If the above port number is other than 80, you must specify the appropriate port number.
Login into the Mobile Server using the administrator user name and password.
Click Mobile Manager. Select the Mobile Server tab and then click Host name.
Click Applications and publish the JAR file that you just created.
Perform the following to test your BC4J application:
Log on to the Mobile Server with the administrator username and password.
Select Mobile Manager.
Click on the Mobile Server tab.
Select the host.
Create a new user called
tutorial and grant permission to this user for the "Oracle Lite Tutorial Application".
Test the application by executing the BC4J application on the Webt-to-Go Mobile client, as described in Section 20.6, "Running the BC4J Application on the Mobile Client for Web-to-Go".
To execute the BC4J application on the Mobile Client for Web-to-Go, perform the following steps.
Using the following URL, check the Oracle database server IP address setup.
Download and install the Mobile Client for Web-to-Go with BC4J support.
Using the following URL, check the local host in the client machine.
Log in to the client machine using
tutorial as both the user name and password.
After the client machine synchronizes the application and data from the server, click the 'Oracle Lite Tutorial Application' link to test the application on the client machine.
To deploy the sample application, perform the following steps.
Log in to the database as a system user. If the
SCOTT schema does not exist already, execute the
OracleLite_BC4J_Tutorial.jar file. It is found under the following directory.
Using the Mobile Manager, publish the above
.jar file into the Mobile Server and enter the following virtual path.
Click Mobile Manager and click Applications.
Click the 'Oracle Lite BC4J Application' link. The Properties page appears.
tiger as the database password and click Save.
Navigate back to the Mobile Manager home page and click the Users link. In case the user
tutorial doesn't exist already, add this user, as described in Section 20.5, "Testing the BC4J Application".
Click Applications and select 'Oracle Lite BC4J Application.' To provide access to the 'Oracle Lite BC4J Application', click Access and assign the access privilege to the user named
Using the following URL, browse the client machine with BC4J support.
Download and install the Mobile Client for Web-to-Go.
If not started already, start the Mobile Client for Web-to-Go.
Log in to the Mobile Client for Web-to-Go with
tutorial as the user name and password.
Upon completion of the Synchronization process, the system displays the 'Oracle Lite BC4J Application' link.
Click the 'Oracle Lite BC4J Application' link to access the BC4J tutorial application.