Enterprise Beans Tutorial

Home| Forums | Join Google Group | Join Yahoo Group | Jobs
Get custom programming done at GetAFreelancer.com!
Earn Money
  Trading Forex Online
  Paramount Airways
  Free Data Recovery
 Cargo
 Job Portal
  HSBC Investment
 Management
 Cheap Web Hosting
  Make Trip
  Cheap Air Travel
 Leisure Hotel
  Free Air Travel
  Mutual Fund Informations
   Cheapest Cellular Plan
 Free Sexy Indians
  Call Center Software
  Hot Indian
Programming Help | Homework Help | Counseling
Astrology Advice | Tarot Advice | Parenting
Dating Advice | Love Advice | Divorce Advice
Legal Advice | Debt Advice | Career Advice

Enterprise Beans Tutorial


31 Database Connections The EJB container maintains the pool of database connections. This pool is transparent to the enterprise beans. When an enterprise bean requests a connection, the container fetches one from the pool and assigns it to the bean. Because the time-consuming connection has already been made, the bean quickly gets a
connection. The bean may release the connection after each database call, since it can rapidly get
another connection.
And because such a bean holds the connection for a short time, the same connection may be shared sequentially by many beans. The persistence type of the 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, the Application Deployment Tool generates the connect routines for you. Coded Connections · The bean routine that connects to the database should not hardcode the actual name (URL) of the
database. Instead, it should refer to the database with a logical name and use a JNDI lookup when
obtaining the database connection. This level of indirection provides several benefits:
o You can deploy the same enterprise bean in different environments that have databases with different names. o You can re-use the enterprise bean in multiple applications. o You can assemble the enterprise beans into applications that run in a distributed environment. (The enterprise beans and the databases they access may run on different machines.) · A resource manager is a storage mechanism such as a DBMS. · A resource manager connection is an object, such as java.sql.Connection, that represents a session
with the resource manager (DBMS).
· A resource manager connection factory is an object that creates resource manager connections. For
example, a javax.sql.DataSource object is a connection factory because it creates a java.sql.Connection
object.
How to Connect The code examples in this section are from the the AccountEJB class, which was described in the the Entity Beans chapter. Because the AccountEJB class uses bean-managed persistence, it connects to the database with the following steps: 1. Specify the logical database name. · private String dbName = "java:comp/env/jdbc/AccountDB";
·
The java:comp/env/ prefix is the JNDI context for the component. · The jdbc/AccountDB string is the logical database name.


Earn Money
  Trading Forex Online
  Paramount Airways
  Free Data Recovery
 Cargo
 Job Portal
  HSBC Investment
 Management
 Cheap Web Hosting
  Make Trip
  Cheap Air Travel
 Leisure Hotel
  Free Air Travel
  Mutual Fund Informations
   Cheapest Cellular Plan
 Free Sexy Indians
  Call Center Software
  Hot Indian