If you are using a J2EE resource connection, such as JDBC and JMS in an Enterprise Bean, release the connection with the close method of the Connection class. If you do not release the connection, the resource might be consumed before you can anticipate the consumption. To avoid such a situation, consider the following points during the implementation:
- Do not maintain the connection in the member variable of the Enterprise Bean class.
If a connection is maintained in the member variable, the connection will be in the usage status irrespective of the execution of the Bean, leading to a decline in the performance. Therefore, the connection must be acquired and released during the execution of the SQL.
- Set up a connection pool.
If you set up a connection pool, the overheads of acquiring a connection to re-use a physical connection can be reduced. When executing under a JTA transaction, you must set up a connection pool.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.