Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Accessing data-source Properties from Action Class

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I want to access the driverClassName,url,username and properties of <data-source> from the struts-config.xml. Currently, I am accessing these values from <context-param> from web.xml but defining the same values in two different files doesn't sound fine.... I have been trying to get a solution to see these <data-source> preperties from the Action class directly but no luck yet.... Does anyone have the solution to my problem??

Thank you
Vikas Sharda
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, get the module configuration like this:

Then get the DataSourceConfig like this:

Once you have this object, you can use its getProperties() method to get a Map of attributes and values. "url", "username", etc. will all be keys in this Map.
 
Vikas
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works!! Thank you so much Merrill!!

But it is not findDataSource(String) method but it's findDataSourceConfig(String)method that worked findDataSource() is not found in my API.... may be its available in previous versions!!

Thank you once again!!
[ August 24, 2006: Message edited by: Vikas Sharda ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic