File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes [struts] using custom DB connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "[struts] using custom DB connection pool" Watch "[struts] using custom DB connection pool" New topic

[struts] using custom DB connection pool

nacho lorente

Joined: Jul 22, 2002
Posts: 1
I have been using a connection pool manager for my applications for a long time and it works fine. So now, I need to export its functionality to struts-way-of-doing-things.
My DBConnectionManager takes its properties (user, pass, URL, maxConn, minConn, ...) from a file. Migrating to struts-way I've seen that all that properties are specified in the <data-source> tag.
Ok. Now come my questions:
1.- the <data-source> tag has a "key" attribute. How can I reach it? I mean, once I give a name to that pool in the struts-config.xml file (I undertand this will be the name of my pool), I need to reference it somehow in my application to create a release() method that let me to empty the pool.
2.- the className attribute of the <data-source> tag makes me to create a extended DataSourceConfig class. Do I really need to create another class? is the properties field not enough? the class has the addProperty() method (which I don't know where to use)...
3.- I understand that I have to access that class extending DataSourceConfig from my ActionServlet, but I don't have the faintest idea of how to do it...
4.- Finally, I understand the type attribute is the one that references my DBConnectionManager. Do I have to change my class, making it an implementation of javax.sql.dataSource? Originally my class was a singlenton in the common package. If I need two or more applications accessing it, can it still be a singleton? or would two distinct applications accessing the same singleton class interfere with eachother?
Thanks a lot..
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Hi Nacho,
Me too am thinking about how to implement connection pooling in struts.
Here is a sample website and an article by Tim Holloway who participates here. He uses a database.

sample site:
azure ss

Joined: Jul 02, 2002
Posts: 6
don't like the way to hardcoded the database username and password in a text file.Any example to show how to use input data to connect to the backend database in struts?
I agree. Here's the link:
subject: [struts] using custom DB connection pool
It's not a secret anymore!