File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Accessing data source inside Action servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Accessing data source inside Action servlet" Watch "Accessing data source inside Action servlet" New topic

Accessing data source inside Action servlet

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Ok I've extended the ActionServlet for a web app so I could initialize values in the servletContext from the database. How can I access the datasources that are set up in the struts-config?
I've found a method which seems to be depracated (and didn't work): getDataSource(String name);
and then I found a member called dataSources which is a "fastHashMap"
And I'm not quite sure how to get the dataSource from it. I'm only using one data source so its not "keyed".

I agree. Here's the link:
subject: Accessing data source inside Action servlet
Similar Threads
Readin struts-config.xml from Action
JasperReports and databases
Loading application scope variables on startup.
dynamically lookup datasources from stateless sessin bean
How to make a data source connection without writing a User name & Password and the -ds.xml file