Clojure:解决korma中mysql utf8的问题

当使用korma内置的mysql方法时,无法添加utf-8的支持。解决的方法就是重写mysql方法,代码如下:

(defn mysql
  "改编自korma,添加了utf-8的支持"
  [{:keys [host port db make-pool?]
    :or {host "localhost", port 3306, db "", make-pool? true}
    :as opts}]
  (merge {:classname "com.mysql.jdbc.Driver" ; must be in classpath
          :subprotocol "mysql"
          :subname (str "//" host ":" port "/" db "?useUnicode=true&characterEncoding=UTF-8")
          :delimiters "`"
          :make-pool? make-pool?}
         opts))
posted @ 2014-07-24 09:10  GreatK  阅读(478)  评论(0编辑  收藏  举报