users@glassfish.java.net

Re: Glassfish Thread Pool allocation question (relates to EJB3 lifecycle)

From: <glassfish_at_javadesktop.org>
Date: Tue, 09 Dec 2008 10:27:12 PST

Connections tend to be heavyweight so it's best not to hold on to them for the duration of the bean instance. It's preferable to use a Java EE resource-ref or @Resource dependency to acquire
the ConnectionFactory.

Keep the connection factory in your instance state, but acquire the actual connection on demand
only as you need to use it, then close it. This will take advantage of the container's underlying
connection pooling. That way you get the most efficient use of the physical connections, while
minimizing the overhead of connection acquisition.
[Message sent by forum member 'ksak' (ksak)]

http://forums.java.net/jive/thread.jspa?messageID=320851