How do can I change the DSN dynamically in ColdSpring through ColdBox?
What are you trying to do? Why would you need to change it dynamically?
By using the environment interceptor I have the coldbox.xml setting
<Datasources> depend upon the environment. It works like this:
<!--- coldbox.xml --->
<Datasources>
<Datasource alias="globalDSN" name="myDSNName" dbtype="mysql"
username="" password="" />
</Datasources>
<!--- make sure the environmentinterceptor is active --->
<!-- USE ENVIRONMENT CONTROL -->
<Interceptor class="coldbox.system.interceptors.environmentControl">
<Property name='configFile'>config/environments.xml.cfm</Property>
</Interceptor>
<!--- I define the dsn in each environment in the
environments.xml.cfm :--->
<Setting name="Datasources.globalDSN.name" value="mydsnname" />
I use transfer so I call the globalDSN set earlier. globalDSN is set
in the environments.xml:
<Property name="datasourceAlias">globalDSN</Property>
otherwise you just access the value of DSN via getSetting
("datasource").getName()
Marc