Spring MVC: Set property value based on input -


i have login page have select database should connect enter image description here

i have configuration this:

	<bean id="datasource"  		class="org.apache.commons.dbcp.basicdatasource">  		<property name="driverclassname" value="com.ibm.db2.jcc.db2driver" />  		<property name="url" value="jdbc:db2://my_server:10000/database_1" />  		<property name="username" value="galadm" />  		<property name="password" value="galadm" />  	</bean>

i using spring jdbc template can write this

<property name="url" value="jdbc:db2://my_server:50000/database{database_which_i_get_from_input}" />

i don't mind have initial value i.e. database_1

seems abstractroutingdatasource viable solution you. layer acts intermediary between multiple datasource, , determines 1 use dynamically.

the following blog solution describes how can switch based on attribute of user’s context

https://spring.io/blog/2007/01/23/dynamic-datasource-routing/


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -