Created
April 1, 2013 18:08
-
-
Save d1rtym0nk3y/5286580 to your computer and use it in GitHub Desktop.
per application datasource parsed from environemnt variable with Railo 4.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
sysenv = createObject("java", "java.lang.System").getenv(); | |
dbUri = createobject("java", "java.net.URI").init(env("DATABASE_URL")); | |
this.datasources.default = { | |
class:'org.gjt.mm.mysql.Driver' | |
,connectionString:'jdbc:mysql://#dbUri.getHost()##dbUri.getPath()#?#dburi.getQuery()#' | |
,username: listfirst(dbUri.getUserInfo(), ":") | |
,password: listlast(dbUri.getUserInfo(), ":") | |
}; | |
this.datasource="default"; | |
private function env(required string name, string default) { | |
var result = variables.sysenv.get(name); | |
if(!isNull(result)) return result; | |
if(!isNull(arguments.default)) return arguments.default; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment