Database Connections for Enterprise Beans
The persistence type of an enterprise bean determines whether or not you code the connection routine. You must code the connection for enterprise beans that access a database and do not have container-managed persistence. Such beans include entity beans with bean-managed persistence and session beans. For entity beans with container-managed persistence, deploytool generates the connection routines for you.
Coded Connections
How to Connect
The code examples in this section are from the SavingsAccountBean class, which connects to the database via the following steps.
1. |
Specify the database name.
private String dbName = "java:comp/env/jdbc/SavingsAccountDB"; |
2. |
Obtain the DataSource associated with ... |
Get J2EE™ Tutorial, The 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.