Reproduced from original post here.
Datasources in ColdFusion have always been defined either in CFAdmin or through Admin API. This made it difficult for applications to be portable across ColdFusion servers.
CF11 brings application specific datasources to ColdFusion. With this, applications can register their own datasources (when they start) without messing with the server-wide datasources defined in CFAdmin. The datasource details can be defined in Application.cfc
Syntax:-
————
- this.datasources.derbyds={ driver=”Apache Derby Embedded”, database= “C:/dev/ColdFusion/cf_main/cfusion/db/artgallery/”};
- this.datasources.dsn1={“database”=”regression”,”host”=”localhostMSSQL2008″, “driver”=”MSSQLServer”, “username”=”sa”, “password”=”password”};
- this.datasources.dsn2={“driver”=”MSSQLServer”, url=”jdbc:macromedia:sqlserver://localhostMSSQL2008; databaseName=regression; sendStringParametersAsUnicode=false; querytimeout=0; MaxPooledStatements=1000″, “username”=”sa”, “password”=”pass”};
- this.datasources.customDSN = { “driver” = “other”, “url” = “jdbc:sqlserver://localhostMSSQL2008; databaseName=pubs; sendStringParametersAsUnicode=false”, “username” = “sa”, “password” = “password”, “class” = “com.microsoft.sqlserver.jdbc.SQLServerDriver”};
If you are using a custom driver, you can use the last syntax given above and specify the driver class.
If you are using drivers shipped by ColdFusion, you can specify the driver and the corresponding driver class will be picked up by ColdFusion.
Possible values for driver are all provided in neo-drivers.xml.
Note: If there is a server-wide datasource with the same name as application datasource, the latter will be picked up.
Allyson, that’s discussed here:
Docs link for this feature.. https://wikidocs.adobe.com/wiki/display/coldfusionen/Application+variables
Encrypted password is not yet there.
Thie feature is mainly for making applications portable. There is no easy way to use an encrypted password while still keeping the application portable. You would have to package the decryption key as well.
Just an update, the doc page for this feature is now at https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/application-variables.html (and see detailed discussion for this in particular here or by searching for the discussion of “application-specific datasources”.)
Sweet! Is this in the docs somewhere? Also, can I specify an encrypted password like Railo allows?
http://blog.getrailo.com/post.cfm/railo-4-1-explicit-datasources-in-application-cfc
You must be logged in to post a comment.