Creating a Session Bean That Does Some Work

The main purpose of the HelloWorldSession example was to get you familiar with the overall structure of a session bean. Writing three different Java files for a single component seems overwhelming at first, but after you're used to it, it doesn't seem like such a big deal.

Now that you're familiar with the structure of a session bean, you can write a bean that does some work. Specifically, you can write a bean that retrieves data from a database. For this example, assume that you have an SQL table containing product codes and prices, created using the following SQL statement:

create table price
    (product_code varchar(10) not null primary key,
     price decimal(10,2) not null)

The Pricing session bean gives ...

Get Special Edition Using Java™ 2 Enterprise Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.