O'Reilly logo

Applied Enterprise JavaBeans™ Technology by Kevin Boone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.6. EJB and JDBC example

The JdbcTest EJB demonstrates the JDBC API features described in this chapter, and simple usage of JDBC in an EJB. This is a stateful session EJB, exposing two methods to clients: executeQuery(), which executes the supplied SQL query and returns the results as a printable text string, and getMetaData(), which generates a text string containing some general information about the database. The implementation class is shown in Listing 8.2. Note that the database connection is only opened as required, and closed immediately afterwards, following modern practice (see below). The client creates this EJB by passing the JNDI name of a DataSource to the create() method on the home interface (Listing 8.3). The remote interface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required