22 Mar 2014, 23:57

Blake Watson (2 posts)

Liking the book overall so far, though I agree with the sentiments re LightTable. (It is the easiest to get started with WHEN it works. Or was until recently, anyway: CounterClockwise’s one-click install probably beats it now.)

Anyway: Trying to do the first DB exercise and getting the above error. In full:

IllegalArgumentException db-spec [:classname “org.sqlite.JDBC” :subprotocol “sqlite” :subname “db.sq3”] is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:192)

From the code in clojure.java.jdbc, it looks like this should work, making me think I’ve got some kind of spelling error in the :classname, subprotocol or subname keyword, but they look right in the error message.

And in the code:

(def db [:classname “org.sqlite.JDBC” :subprotocol “sqlite” :subname “db.sq3”])

(defn create-guestbook-table [] (sql/with-connection db (sql/create-table :guestbook [:id “INTEGER PRIMARY KEY AUTOINCREMENT”] [:timestamp “TIMESTAMP DEFAULT CURRENT_TIMESTAMP”] [:name “TEXT”] [:message “TEXT”]) (sql/do-commands “CREATE INDEX timestamp_index ON guestbook (timestamp)”)))


24 Mar 2014, 20:02

Blake Watson (2 posts)

This appears to be a Windows thing. I don’t know quite how or why, but it runs fine on Ubuntu. Weirdly, I found a sample that works on Windows at github:


Though damned if I can tell what the difference is. I mean, the way the files are incorporated are different, but I can’t see why that would make a difference (and I can’t seem to transplant the working code to the book code to get it to work). In the book, it’s:

(ns guestbook.models.db (:require [clojure.java.jdbc :as sql]) (:import java.sql.DriverManager))

Whereas in this working code, it’s:

(ns clojure-sqlite-example.core (:use [clojure.java.jdbc]))

So, the example doesn’t use java.sql.DriverManager. From what I can tell, the book code doesn’t need java.sql.DriverManager to work, either.

  You must be logged in to comment