 (defn create-db [file]
   (kdb/create-db  {:classname "org.h2.Driver"
                    :subprotocol "h2"
-                   :subname file}))
+                   :subname file
+                   :make-pool true}))
 
 (defmacro with-db [db & body]
   `(kdb/with-db ~db ~@body))

;       (hash-by-key :SAMPLE)
;       (in-order sample-list)
;       (select-val :ID)))

(defn- insert-exp-sample [eid sample i]
  (insert exp_samples (values {:experiments_id eid :name sample :i i})))

(defn- load-exp-samples [exp samples]
  (dorun (map #(apply (partial insert-exp-sample exp) %)
              (map vector samples (range)))))

(let [fmtr (formatter "yyyy-MM-dd hh:mm:ss")]
  (defn- format-timestamp [timestamp]

(defn- col-arrays [columns n]
  (zipmap columns (repeatedly (partial float-array n))))

(def probe-query
  "SELECT  gene, i, expscores from
     (SELECT  `probes`.`name` as `gene`, `probes`.`id`  FROM `probes`
       INNER JOIN TABLE(name varchar=?) T ON T.`name`=`probes`.`name`
       WHERE (`probes`.`eid` = ?)) P
   LEFT JOIN `joins` on P.id = `joins`.`pid`
   LEFT JOIN `scores` ON `sid` = `scores`.`id`
   WHERE `joins`.`i` in (%s)")

(defn select-scores-full [eid columns bins]
  (let [q (format probe-query
                  (clojure.string/join ","
                                       (repeat (count bins) "?")))
        c (to-array (map str columns))
        i (to-array bins)]
    (exec-raw [q (concat [c eid] i)] :results)))

; Doing an inner join on a table literal, instead of a big IN clause, so it will hit
; the index.
(defn genomic-read-req [req]
  (let [{samples 'samples table 'table columns 'columns} req
        eid (exp-by-name table)
