Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move the environment details outside the EAR

Our project is a medium size web application developed using RAD 7.0 on WAS 6.1/hibernate/struts which moved to production. Currently we have hardcoded the ip address of the production system in the property file and database schema details in the hibernate config file.

Our client wants us to come up with the solution for keeping the environment details out side the EAR, so that they can change the environment/db details in future with out opening the EAR .

Any pointers would be very helpful. Thanks.


1 Answers

You can use JNDI for this. You should create the appropriate entries and in your code read them like this:

Context initialContext = new InitialContext();
URL ip = (URL) initialContext.lookup("java:comp/env/myip");

See this article on how to use a JNDI Data Source in hibernate configuration files.

like image 194
kgiannakakis Avatar answered Nov 26 '25 21:11

kgiannakakis