2. Using the Tutorial Examples
3. Getting Started with Web Applications
Deploying a Packaged Web Module
Updating a Packaged Web Module
Mapping URLs to Web Components
Setting Initialization Parameters
Mapping Errors to Error Screens
Declaring a Reference to a Resource
Declaring a Reference to a Web Service
Further Information about Web Applications
5. JavaServer Pages Technology
7. JavaServer Pages Standard Tag Library
10. JavaServer Faces Technology
11. Using JavaServer Faces Technology in JSP Pages
12. Developing with JavaServer Faces Technology
13. Creating Custom UI Components
14. Configuring JavaServer Faces Applications
15. Internationalizing and Localizing Web Applications
16. Building Web Services with JAX-WS
17. Binding between XML Schema and Java Classes
19. SOAP with Attachments API for Java
21. Getting Started with Enterprise Beans
23. A Message-Driven Bean Example
24. Introduction to the Java Persistence API
25. Persistence in the Web Tier
26. Persistence in the EJB Tier
27. The Java Persistence Query Language
28. Introduction to Security in the Java EE Platform
29. Securing Java EE Applications
31. The Java Message Service API
32. Java EE Examples Using the JMS API
36. The Coffee Break Application
37. The Duke's Bank Application
Data that is shared between web components and is persistent between invocations of a web application is usually maintained in a database. To maintain a catalog of books, the Duke’s Bookstore examples described in Chapters Chapter 4, Java Servlet Technology through Chapter 15, Internationalizing and Localizing Web Applications use the Java DB database included with the Application Server.
To access the data in a database, web applications use the new Java Persistence API (see Chapter 24, Introduction to the Java Persistence API). See Chapter 25, Persistence in the Web Tier to learn how the Duke’s Bookstore applications use this API to access the book data.
To run the Duke’s Bookstore applications, you need to first populate the database with the book data and create a data source in the Application Server. The rest of this section explains how to perform these tasks.
When you deploy any of the Duke’s Bookstore applications using ant deploy, the database is automatically populated at the same time. If you want to populate the database separately from the deploy task or are using NetBeans IDE to deploy the application, follow these steps:
In a terminal window, go to the books directory or any one of the bookstore1 through bookstore6 example directories.
Start the Java DB database server. For instructions, see Starting and Stopping the Java DB Database Server. You don’t have to do this if you are using NetBeans IDE. It starts the database server automatically.
Type ant create-tables. This task runs a command to read the file tut-install/examples/common/sql/javadb/tutorial.sql and execute the SQL commands contained in the file.
At the end of the processing, you should see the following output:
... [sql] 181 of 181 SQL statements executed successfully
When you are running create-tables, don’t worry if you see a message that an SQL statement failed. This usually happens the first time you run the command because it always tries to delete an existing database table first before it creates a new one. The first time through, there is no table yet, of course.
A DataSource object has a set of properties that identify and describe the real world data source that it represents. These properties include information such as the location of the database server, the name of the database, the network protocol to use to communicate with the server, and so on.
Data sources in the Application Server implement connection pooling. To define the Duke’s Bookstore data source, you use the installed Derby connection pool named DerbyPool.
You create the data source using the Application Server Admin Console, following this procedure:
Expand the Resources node.
Expand the JDBC node.
Select the JDBC Resources node.
Click the New... button.
Type jdbc/BookDB in the JNDI Name field.
Choose DerbyPool for the Pool Name.
Click OK.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices
Scripting on this page tracks web page traffic, but does not change the content in any way.