Created
May 23, 2011 03:23
-
-
Save anonymous/986166 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
project.clj | |
(defproject sqlex "1.0.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:dependencies [[org.clojure/clojure "1.2.1"][mysql/mysql-connector-java "5.1.6"]]) | |
core.clj: | |
(ns sqlex.core | |
(:use clojure.contrib.sql)) | |
(let [db-host "127.0.0.1" | |
db-port 3306; | |
db-name "mysql"] | |
; The classname below must be in the classpath. | |
(def db {:classname "com.mysql.jdbc.Driver"; | |
:subprotocol "mysql"; | |
:subname (str "//" db-host ":" db-port "/" db-name) | |
; Any additional map entries are passed to the driver | |
; as driver-specific properties. | |
:user "root" | |
:password "xxx"}) | |
(with-connection db ; closes connection when finished | |
(with-query-results rs ["select * from Employee"] ; closes result set when finished | |
; rs will be a non-lazy sequence of maps, | |
; one for each record in the result set. | |
; The keys in each map are the column names retrieved and | |
; their values are the column values for that result set row. | |
(doseq [row rs] (println (row :lastname))))) | |
$ sh lein.sh clean | |
Cleaning up. | |
$ sh lein.sh deps | |
Copying 2 files to C:\cygwin\home\ryan\sqlex\lib | |
$ sh lein.sh classpath | |
C:\cygwin\home\ryan\sqlex\src;C:\cygwin\home\ryan\sqlex\test;C:\cygwin\home\ryan\sqlex\classes;C:\cygwin\home\ryan\sqlex\test-resources;C:\cygwin\home\ryan\sqlex\resources;C:\cygwin\home\ryan\sqlex\lib\clojure-1.2.1.jar;C:\cygwin\home\ryan\sqlex\lib\mysql-connector-java-5.1.6.jar | |
$ sh lein.sh test | |
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/contrib/sql__init.class or clojure/contrib/sql.clj on classpath: (core.clj:1) | |
at clojure.lang.Compiler.eval(Compiler.java:5440) | |
at clojure.lang.Compiler.load(Compiler.java:5857) | |
at clojure.lang.RT.loadResourceScript(RT.java:340) | |
at clojure.lang.RT.loadResourceScript(RT.java:331) | |
at clojure.lang.RT.load(RT.java:409) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment