Spring MVC: Set property value based on input -
i have login page have select database should connect 
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
Post a Comment