aspose file tools
The moose likes Struts and the fly likes [struts] using custom DB connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "[struts] using custom DB connection pool" Watch "[struts] using custom DB connection pool" New topic
Author

[struts] using custom DB connection pool

nacho lorente
Greenhorn

Joined: Jul 22, 2002
Posts: 1
Hi!
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 db.properties 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..
Nacho
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: http://www.mousetech.com/strutdemo/index.jsp
article:
http://www.fawcette.com/javapro/2002_04/magazine/features/tholloway/
Axel
azure ss
Greenhorn

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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: [struts] using custom DB connection pool
 
Similar Threads
javax.naming.NamingException: Could not dereference object
why jsp cannot use this class, which is no problem when compile singlely.
pool name in DBConnectionManager
JNDI Port number issue while strating JBoss server 4.2.2.GA
Lost properties