java - Creating a datasource from fetching the data source -


currently,i storing database details in property file , creating datasource using

<bean id="datasource" class="org.apache.commons.dbcp.basicdatasource">     <property name="driverclassname">         <value>${driverclassname}</value>     </property>     <property name="url">         <value>${url}</value>     </property>     <property name="username">         <value>${username}</value>     </property>     <property name="password">         <value>${password}</value>     </property> </bean> 

my client asked place config database , db store i18keys , main database values.

so need create 1 2 datasources 1 configs , other main database.

i can create config data sources using same. how can create second datasource database details stored in config database.

can pointers helpful.

you might take java-configuration spring. can combine current xml-configuration using <context:component-scan base-package="..."/>.

the general approach configure first datasource configuration (like in current setup) using xml. xml should refer 'configuration class'.

that special class, annotated @configuration, gets first datasource injected (or maybe dao), , defines method so:

@bean public datasource seconddatasource() {     // construct second datasource using configuration     // retrieved first datasource.     return new basicdatasource(); } 

note might want add qualifier either (or both) datasources can distinguish between 2 datasources when want have them injected other beans using @injector @autowired.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -