Skip to content

Instantly share code, notes, and snippets.

@samsondav
Created June 6, 2015 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsondav/616627066d593a1275cc to your computer and use it in GitHub Desktop.
Save samsondav/616627066d593a1275cc to your computer and use it in GitHub Desktop.
Extract DATABASE_URL environment variable for app running inside Apache Tomcat
(import [javax.naming Context InitialContext])
(def development-db-string "postgresql://localhost:5432/foobar_db")
(def db-uri
(atom
(try
(. (. (InitialContext.) lookup "java:comp/env") lookup "DATABASE_URL") ; will pull environment variables from a Tomcat server
(catch javax.naming.NoInitialContextException e
(or
(System/getenv "DATABASE_URL")
development-db-string)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment