tracker issue : CF-3656754

select a category, or use search below
(searches all categories and all time range)
Title:

Allow per-application data sources created in Application.cfc

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood (Bradley Wood)

Created: 10/30/2013

Components: Database

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final / 288219

Priority/Frequency: Major / Unknown

Locale/System: English / Platforms All

Vote Count: 1

In the same manner that ColdFusion mappings can be created at the server level and overridden by a single application with code, allow for developers to specify data sources in their Application.cfc.

This would be of great use for applications such as ContentBox Modular CMS on a shared environment as the app could install itself automatically on the user's server without needing admin access. This feature currently exists in Railo Server and looks like this:

component {
 
  this.name = "AppName";
 
  // With JDBC URL (Other)
  this.datasources.myDatasource={
    class:'org.gjt.mm.mysql.Driver'
    ,connectionString:'jdbc:mysql://localhost:3306/demo_db?characterEncoding=UTF-8&useUnicode=true'
    ,username:'demouser'
    ,password:"encrypted:5943217a74b3d570f7ed78738da72bb4972228f46c8f9b7e96f5e995d66d1e9a"
  };

  // By datasource "type"
  this.datasources.myOtherDatasource={
  	  type:'MySQL'
	  ,host:'localhost'
	  ,port:3306
	  ,database:'demo_db'
	  ,username:'demouser'  
    	  ,password:'demouser'
	  ,custom:{ characterEncoding:'UTF-8' ,useUnicode:true }
  };
  
}

More info on Railo implementation: http://blog.getrailo.com/post.cfm/railo-4-1-explicit-datasources-in-application-cfc

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3656754

External Customer Info:
External Company:  
External Customer Name: bradwood.com
External Customer Email:

Attachments:

Comments:

Forget *box-specific references, this just makes sense for anyone wanting to have a transportable app. CF used to have code-conifgured DSNs (until CFMX), and it makes sense to still have them. -- Adam
Vote by External U.
14036 | October 30, 2013 06:26:19 PM GMT
This issue is fixed in the next major version of ColdFusion.
Comment by Nimit S.
14031 | March 03, 2014 07:59:25 AM GMT
Has this actually been implemented? It says it's fixed in build 288219, which should - I would have thought - been included in the CF11 public beta which is 11,0,0,288464. However I cannot get it to work. Also... I did not notice anything in the beta docs about this. Did you follow the implementation as per the Railo doc Brad linked to? It's very good news this is being done, btw. Thanks. -- Adam
Comment by External U.
14032 | March 31, 2014 06:49:07 AM GMT
Hello?
Comment by External U.
14033 | April 26, 2014 11:17:22 AM GMT
Adam, this has been implemented, but not in the same manner as Railo. I just tested it last week. Basically, you can access the mappings currently defined for the application by calling the getApplicationMetadata() function and then manipulating the "mappings" struct that it returns. function addMappingCF( name, path) { var appSettings = getApplicationMetadata(); appSettings.mappings[ name ] = path; } Keep in mind, this must be done on every request, since the Application.cfc is re-created on every request. As a general note here, the same can be accomplished in CF8, 9, and 10 using an undocumented method in the application scope. I might blog this just because it is interesting. // For CF10, Add the mappings into the the application settings map // This is because getApplicationMetadata().mappings is null if none exist function addMappingCF10( name, path) { var appSettings = application.getApplicationSettingsMap(); appSettings.mappings[ name ] = path; } // CF9 is same as CF10, but with Slightly different method name function addMappingCF9( name, path) { var appSettings = application.getApplicationSettings(); appSettings.mappings[ name ] = path; }
Comment by External U.
14034 | April 26, 2014 02:21:52 PM GMT
Opps, CF8 was a typo. I never actually tried it there.
Comment by External U.
14035 | April 26, 2014 02:24:01 PM GMT