This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[struts] using custom DB connection pool

 
nacho lorente
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic