This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to create single connection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to create single connection?" Watch "How to create single connection?" New topic

How to create single connection?

Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
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

Judge a man by his questions rather than his answers --Voltaire
SCJP 1.5 97%
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344


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?

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
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 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);
I agree. Here's the link:
subject: How to create single connection?
Similar Threads
Could not get the connection in struts database application
DataSource issues
Connection to data source on the basis of userlogin using JPA
Database and J2ee server help needed!
Problem in inserting values to database from action class