ColdBox, ColdSpring and switching DSN's

4 views
Skip to first unread message

spiraldev

unread,
Dec 15, 2009, 12:03:06 PM12/15/09
to ColdBox Platform
How do can I change the DSN dynamically in ColdSpring through ColdBox?

Dutch Rapley

unread,
Dec 15, 2009, 12:44:19 PM12/15/09
to col...@googlegroups.com
What are you trying to do? Why would you need to change it dynamically?

On Tue, Dec 15, 2009 at 12:03 PM, spiraldev <spir...@gmail.com> wrote:
How do can I change the DSN dynamically in ColdSpring through ColdBox?

--
You received this message because you are subscribed to the Google Groups "ColdBox: A ColdFusion Framework" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For more information, visit http://www.luismajano.com/projects/coldbox
For Documentation, visit http://ortus.svnrepository.com/coldbox/trac.cgi

marc

unread,
Dec 26, 2009, 3:31:09 PM12/26/09
to ColdBox Platform
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

Reply all
Reply to author
Forward
0 new messages