On Oct 13, 2004, at 12:43 AM, Gary Jarrel wrote:
> Hi All!
>
> Has anyone got some best practices on integrating cayenne with 3rd party
> connection poolers such as proxool or dbcp?
I'm not going to comment on whether or not this qualifies as "best practices" or not :), but this is what I'm using right now in a web app:
I'm letting Tomcat handle the heavy lifting as far as managing the connection pool itself - for one, it comes with DBCP, and for two, it's very painless to make the connection pool available to the web application as a JNDI-mapped DataSource. The details of the connection pool configuration (and JNDI resource mapping) are specified in context.xml; to access the resource from your application, you have to add a resource-ref block in web.xml that tells the application what the JNDI name of the resource is and how authentication is handled.
To make this all known to Cayenne is actually quite simple - in the modeler, you configure your DataNode to use the JNDIDataSourceFactory and specify the JNDI name of the DataSource (connection pool) that you defined in context.xml.
As for why I chose to do it this way... Well, it mostly boils down to being slightly lazy and not wishing to manage the connection pool manually - if the container can do it (and Tomcat hasn't done anything weird under my testing so far), I figure I might as well let it, unless there is a burning reason to do otherwise.
This might all sound a bit confusing, but it's really not... the config is pretty simple. :) If you'd like an example, I could send you mine - just email me off-list.
Cheers,
Bryan
This archive was generated by hypermail 2.0.0 : Wed Oct 13 2004 - 11:53:21 EDT