Working with JDBC Through a Full Example

Now it's time for todayís example. Listing 9.1 gives a skeleton of code that performs the following:

  • Connects to a database

  • Performs few of both DDL and DML statements

  • Queries ResultSet metadata and database metadata

  • Closes the statements and the connection

  • Handles SQL exceptions

To demonstrate the strong aspect of JDBC as a vendor-neutral API, the same example runs on two different application servers, without changing any line of code. The QueryDB session bean is used to represent the client in query the database. Listings 9.1 to 9.3 are for the home interface, remote interface, and the bean class. Listings 9.4 to 9.7 are for the EJB client, standard deployment descriptor, WebLogic Server deployment descriptor, ...

Get Sams Teach Yourself EJB in 21 Days now with O’Reilly online learning.

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