Application datasources in ColdFusion

August 11, 2014
Followers: 0 people
4

Application datasources in ColdFusion

Followers: 0 people
August 11, 2014

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.

Comments (4)
2018-08-09 15:24:03
2018-08-09 15:24:03

Hi. I am wondering where we locate the application.cfc file in order to change the datasource?

Like
2014-08-18 22:27:09
2014-08-18 22:27:09

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.

Like
2014-08-18 10:48:56
2014-08-18 10:48:56

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

Like
Add your comment