8.5. JDBC and JNDI

Any EJB can use JDBC calls to interact with a database, except entity EJBs with container-managed persistence. In that case, the database interaction is implemented by the container. Entity EJBs will almost always require database connectivity, but session and message-driven EJBs will often interact with a database as well. [3]

[3] The improvements in the entity EJB architecture introduced with EJB2.0 have reduced the need for session and message-driven EJBs to interact directly with databases.

EJBs obtain a connection to the database using the EJB server’s JNDI implementation—that is, they perform a lookup() call on the InitialContext or one of its subcontexts. The name supplied to the lookup() call is arbitrary; it will be ...

Get Applied Enterprise JavaBeans™ Technology 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.