Datasource Connection Pool c3p0
first thing : I am not really a java expert, coding a bit -enjoying it- but there are some things that I do not understand.
I am trying to design and code an application (using tomcat 5, with servlets, no beans at the moment) that uses a repository (most likely mysql, but generally a database) and may need to perform many queries against other "n" databases with connections defined by "powerusers".
Looking in this forum and googling around a bit I discovered it would be good to use cp30 with ComboPooledDataSource.
I tested it and it works, so far so good.
Now the problem(s) :
1) I understood (from some posts in this forum) that it is considered better to define the resources in the server.xml file rather than create them dynamically.
It would be quite inconvenient for my app as database connections may be defined by users with the right auth level. Is there, for such a situation, a better solution than bind jndi names in the sourcecode (pars are actually stored in the app repository)?
2) I discovered that ctx.lookup is also an expensive thing to do... then I am in trouble here.
Someone suggested to create a datasource and keep it alive, setting it in the init().
That may work for the repository, not sure how to handle the other "n" connections. (a list, an array... whatever).
How can I create those objects and keep them "alive" for my app? Should I use a listener servlet? (ok, I told you I am not an expert...)
Any suggestion is welcome.
Thanks in advance.
|All times are GMT. The time now is 03:22 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.