Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring question

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My spring application uses an xml file for lookup of datasources. It has all the datasource related entries in each of the datasource entries ( URL, Port No, User Name, password etc). Now we need to take out the login details form out of the file and maintain in a different file. How can I do that? The new file has only the entries of login and password for all the datasources.



Thanks,

vasu
 
Matt Raible
author
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XML you've posted looks like it's your datasource configuration for Tomcat, rather than for Spring. If you're configuring a datasource in one of Spring's context files, you can use a PropertyPlaceholderConfigurer to externalize settings into a properties file.

Read More

I can't think of a way to do this for Tomcat.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can take a look at JConfig

./pope
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt,

This application runs in Spring framework with Hessian used for remote calls.

We are still following the database look up just the way I have posted above. Are you suggesting that I should replace it with a spring context file instead where I have better management of individual properties? IS there no way of doing it leaving it in the tomcat as it is?


Thanks,

Vasu
 
Matt Raible
author
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vasu maj:
Matt,

This application runs in Spring framework with Hessian used for remote calls.

We are still following the database look up just the way I have posted above. Are you suggesting that I should replace it with a spring context file instead where I have better management of individual properties? IS there no way of doing it leaving it in the tomcat as it is?


Yes. If you want to put your settings in another file, then I'd suggest you move your database settings into a spring context file. You mentioned that you don't want to keep these settings in a Tomcat context file. Unless there's a way to do it in Tomcat - putting these settings in a Spring context file seems like a reasonable solution.

You could then use the
PropertyPlaceHolderConfigurer class to move database driver, url, username and password settings into a properties file. Learn More...
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am already using spring framework's database access classes which are really very convenient. I will create the context file and move the databse enrties there.

Thanks very much. Very glad that you are here when I needed the help.

Vasu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic