     (sync-db "dev")
     (add-encoders)
     (run-server (reload/wrap-reload #'all-routes)
-                {:port (Integer/parseInt port) :thread 50})))
+                {:port (Integer/parseInt port) :thread 50})
+    (if (Desktop/isDesktopSupported)
+      (try
+        (doto (Desktop/getDesktop)
+          (.browse (URI. (str "http://localhost:" port))))
+        (catch Exception e
+          (log/warn "failed to open browser" e))))))

  (add-encoder java.sql.Date (date-time-encoder "dd/MM/yyyy"))
  (add-encoder java.sql.Timestamp (date-time-encoder "dd/MM/yyyy HH:mm:ss"))
  (add-encoder java.sql.RowId #(.writeString %2 %1))
  (add-encoder (Class/forName "oracle.sql.ROWID") #(.writeString %2 (.stringValue %1))))

(def ds-cache (atom (cache/lru-cache-factory {})))


(ns dbquery.core
  (:gen-class)
  (:require [cheshire.generate :refer [add-encoder]]
            [clojure.core.cache :as cache]
            [clojure.data.csv :as csv]
            [clojure.java.io :as io]
            [clojure.tools.logging :as log]
            [compojure.core :refer :all]
            [compojure.route :as route]
            [crypto.password.bcrypt :as password]
            [dbquery.databases :as db :refer :all]
            [dbquery.model :refer :all]
            [dbquery.utils :refer :all]
            [korma.core :as k]
            [liberator.core :refer [defresource]]
            [liberator.dev :refer [wrap-trace]]
            [org.httpkit.server :refer [run-server]]
            [ring.middleware.defaults :refer :all]
            [ring.middleware.json :refer :all]
            [ring.middleware.multipart-params :as mp]
            [ring.middleware.reload :as reload]
            [ring.util.response :refer [redirect]])
  (:import java.awt.Desktop
           java.io.FileReader
           java.net.URI
           java.text.SimpleDateFormat
           java.util.Date))

;; custom json encoder for dates
(defn- date-time-encoder [fmt]
