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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.