Created
January 8, 2013 14:44
-
-
Save bouzuya/4484275 to your computer and use it in GitHub Desktop.
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
(require '[clojure.java.jdbc :as sql] | |
'[clojure.java.io :as jio]) | |
(def dbpath | |
(jio/file (System/getProperty "user.home") "derby.example.db")) | |
(def db | |
{:classname "org.apache.derby.jdbc.EmbeddedDriver" ; "derby" も可能 | |
:subprotocol "derby" | |
:subname dbpath | |
:create true}) | |
(sql/with-connection db | |
(try | |
(sql/drop-table :testing) | |
(catch Exception _))) | |
(sql/with-connection db | |
(sql/create-table | |
:testing | |
[:data "varchar(140)"])) | |
(sql/with-connection db | |
(sql/insert-rows | |
:testing | |
["Hello, world!"] | |
["Hello, Apache Derby!"])) | |
(sql/with-connection db | |
(sql/with-query-results results | |
["select * from testing"] | |
(into [] results))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/4484208
の Apache Derby 版。
project.clj
の[org.apache.derby/derby "10.8.1.2"]
も忘れずに。