This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create single connection?

 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my project i used nearly 50 struts config file.In each xml file we defined datasource and getting connection .the problem is i was used 50 struts config file so 50 connection pooling is created.please tell me how to use single datasource to all sub module without defined seperate in each xml.

i tried context.getAttribute(Action.DATA_SOURCE_KEY).BUT I this is deprecated


please tell me
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Struts definitely supports multiple configuration files to be a part of an application.

By looking at the piece of code you have given, it seems you look for the Action.DATA_SOURCE_KEY using which you obtain a single connection only.

I don't get what exactly you need further? Or can you please be a bit more specific?
 
Kaleeswaran Karuppusamy
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i access Action.DATA_SOURCE_KEY?
my code

ServletContext context=servlet.getServletContext();
dataSource =(javax.sql.DataSource)context.getAttribute(Action.DATA_SOURCE_KEY);

error


FilterDispatchAction.java:293: cannot find symbol
symbol : variable DATA_SOURCE_KEY
location: class org.apache.struts.action.Action
dataSource =(javax.sql.DataSource)context.getAttribute(Action.DATA_SOURCE_KEY);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic