;; Grab a JDBC driver for your DB, maybe MySQL from one the mirrors, i.e.
;;   http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.0.8.tar.gz/from/http://mysql.llarian.net/
;;
;; Start Jarc like this:
;;
;; java -cp jarc.jar:mysql-connector-java-5.0.8-bin.jar jarc.Jarc
;;
(use 'sql)

(sql-driver "com.mysql.jdbc.Driver")
(= jdbc-url "jdbc:mysql://localhost/MyDB")
(= db-username "root")
(= db-password "")

(def blah-create ()
  (with-open db (sql-connect jdbc-url db-username db-password)
    (sql-update db
      "CREATE TABLE Blah (
         id     INTEGER NOT NULL PRIMARY KEY,
         value  VARCHAR(100) NULL
       ) TYPE=InnoDB")))

(def blah-insert-values (id value)
  (with-open db (sql-connect jdbc-url db-username db-password)
    (sql-update db "insert into Blah (id,value) values (?,?)" id value)))

(def blah-insert (blah-obj)
  (with-open db (sql-connect jdbc-url db-username db-password)
    (sql-insert db "Blah" blah-obj)))

(def blah-list ()
  (with-open db (sql-connect jdbc-url db-username db-password)
     (with-open stmt (sql-stmt db "select id,value from Blah")
       (with-open rs (sql-query stmt)
	 (while (next rs)
	   (prn (getObject rs 1) "\t" (getObject rs "value")))))))

(def blah-update-values (id value)
  (with-open db (sql-connect jdbc-url db-username db-password)
    (sql-update db "update Blah set value=? where id=?" value id)))

(def blah-update (id blah-obj)
  (with-open db (sql-connect jdbc-url db-username db-password)
    (sql-modify db "Blah" blah-obj "where id=?" id)))

(def blah-drop ()
  (with-open db (sql-connect jdbc-url db-username db-password)
    (sql-update db "drop table Blah")))

(def blah-test ()
   (blah-drop)
   (blah-create)
   (blah-insert-values 10 "can")
   (blah-insert (obj id 11 value "cannot"))
   (blah-list)
   (sql-trace 't)
   (blah-update 11 (obj id 11 value "can't"))
   (blah-list))