DAO and Database Connections

Discussions

General J2EE: DAO and Database Connections

  1. DAO and Database Connections (2 messages)

    Hi,

    I have a doubt on DAOs and Connection handling...

    In my application, I have a Session Faccade (Stateless Session Bean) which accesses a Business Object which in turn calls about three Data Access Objects to perform the database operations. The transaction attribute for the method is the Session Bean is set as "Required". The application uses a DataSource for obtaining the Database Connection. All the three DAOs are using separate connection objects.

    My doubts are:
    1. If I roll back the transaction at any stage will all the three connections get rolled back?

    2. Is it a good idea to obtain separate connections for the DAOs that are taking part in same transaction? Or I should create a connection outside the DAOs and pass it to all the DAOs.

    3. Is DataSource.getConnection() an expensive call that will degrade the application performance.

    Somebody please help....

    Best Regards
    Jaise
  2. DAO and Database Connections[ Go to top ]

    Hi,
    When in the same transaction, DataSource.getConnection() returns a wrapper over the same underlying connection.
    Best regards, Mircea
  3. DAO and Database Connections[ Go to top ]

    Hi,I have a doubt on DAOs and Connection handling...In my application, I have a Session Faccade (Stateless Session Bean) which accesses a Business Object which in turn calls about three Data Access Objects to perform the database operations. The transaction attribute for the method is the Session Bean is set as "Required". The application uses a DataSource for obtaining the Database Connection. All the three DAOs are using separate connection objects.My doubts are:1. If I roll back the transaction at any stage will all the three connections get rolled back?2. Is it a good idea to obtain separate connections for the DAOs that are taking part in same transaction? Or I should create a connection outside the DAOs and pass it to all the DAOs.3. Is DataSource.getConnection() an expensive call that will degrade the application performance.Somebody please help....
    You may be interested in this article:

    http://www-106.ibm.com/developerworks/java/library/j-dao/