Datasource Connection Pool c3p0

Joined
Jun 27, 2008
Messages
1
Reaction score
0
Hello all,
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.

Francesco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top