Skip to content

Instantly share code, notes, and snippets.

@bouzuya
Created January 8, 2013 14:44
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 bouzuya/4484275 to your computer and use it in GitHub Desktop.
Save bouzuya/4484275 to your computer and use it in GitHub Desktop.
(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)))
@bouzuya
Copy link
Author

bouzuya commented Jan 8, 2013

https://gist.github.com/4484208

の Apache Derby 版。

project.clj[org.apache.derby/derby "10.8.1.2"] も忘れずに。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment