This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes get datasource outside action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "get datasource outside action class" Watch "get datasource outside action class" New topic

get datasource outside action class

roseline ruba

Joined: Mar 21, 2007
Posts: 20

Is there any option to get the datasource connection from the non-action class?, where the datasource specified in the struts-config.xml file.

Craig Bayley
Ranch Hand

Joined: Sep 27, 2007
Posts: 46
If the class shares the same InitialContext as the action class, then yes, no worries. You can just get the reference that way:

The <resource reference> corresponds to the context.xml entry (or server.xml entry)
<ResourceParams name="<resource reference">
I agree. Here's the link:
subject: get datasource outside action class
Similar Threads
Error:cannot find getDataSource(req)
Which approach is correct for getting a connection of database from a business class
Struts 1.1 database connection exception
Creating datasource in WAS 5
How to Access SevletContext Object in Action Class