Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are 2 approaches to handling connections:</p> <ul> <li>one connection per request</li> <li>connection on-demand</li> </ul> <p><strong>One connection per request</strong> means you get the connection at the start of the process, and return it at the end. This is not a good idea for web requests, as it means you application can only handle as many concurrent web requests as there are db connections available. However, it can be a good idea for batch processing, where you know you only need N connections.</p> <p><strong>Connection on-demand</strong> means you get the connection when you are about to do make a db call, and then return it as soon as the db call has finished.</p> <p>In both cases, its recommended to use a connection pool, however its especially important for the connection on-demand strategy, as you want the connection to remain open after it is returned, because there is a significant overhead to opening connections.</p> <p>There are generally two ways to handle connection pools:</p> <ul> <li>container managed</li> <li>application managed</li> </ul> <p>Container managed means the application server provides the connection pool to the application via JNDI. This is what JBoss typically does. If it is there, you might as well use this approach. Otherwise, you should use an application managed pool.</p> <p>Most DI frameworks will provide a connection pool for you with a little configuration. There is really no significant downside to using a connection pool. The two most common in java are DBCP and C3P0, both of which are very mature libraries. If you are not using a DI framework, you should review the getting started guides for those libs and implement what they suggest.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload