Update database settings in properties file in Spring
Posted
by
mvg
on Stack Overflow
See other posts from Stack Overflow
or by mvg
Published on 2010-12-25T11:55:57Z
Indexed on
2010/12/25
12:54 UTC
Read the original article
Hit count: 278
Hi all,
I am trying to create a Database Manager page which shows the database details on page load and updates the database settings when the user press submit
I followed this tutorial and set the database settings in properties file.
I managed to update the database settings in properties file programmatically. When I retrieved the database settings using the following code
DriverManagerDataSource databaseSource = (DriverManagerDataSource)context.getBean("dataSource");
databaseSource.getUsername();
I managed to get the old value and unable to get the new value
This is the mapping in applicationContext.xml file
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:/bundle/database.properties</value>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
I checked the properties file and found it to be updated with the latest input.
What am I missing?
Thanks in advance
P.S I am using JSF1.2 with Spring 3
Update
Just making my requirement simple. I am creating a setparate dbsettings page, so that when user wishes to connect to different database he/she can just enter the details in dbsettings page and connect
© Stack Overflow or respective owner