ClojureQL - 0.9 approaching 1.0

11 views
Skip to first unread message

Lau_of_DK

unread,
Jun 29, 2009, 2:01:18 PM6/29/09
to Clojure
Dear community,

Meikel and I have been driving an effort to get ClojureQL to version
1.0.

For those who do not yet know about ClojureQL, its a database adapter
which allows you to interface with MySql, Derby, Sqlite etc, without
ever leaving your lisp syntax. But more than being a syntax thing,
ClojureQL also is able to extend the functionality of databases, ie.
you can currently find an emulator in the backend which enables both
MySql and Derby to do FULL joins - Not something you normally get to
do.

In terms of functionality we almost cover every need that you'll have
when working with SQL, but there are still quirks to be ironed out
(ex. joins) and features to be added and extended (ex. alter table).
But this is where we'd like to appeal to the community to hit us with
some feedback! If you're interested in Clojure/SQL and you can find
the time to experiment a little, its as simple as this.

1) Put the src/ or the jar file on your class-path and get a REPL
going.
2) user> (use 'dk.bestinclass.clojureql) // Import the functions
3) Have fun, ala:

user> (def *connection* (make-connection-info "mysql" "//localhost/
cql" "cql" "cql"))
#'user/*connection*
user> (load-driver "com.mysql.jdbc.Driver")
com.mysql.jdbc.Driver
user> (run [*connection* results] (query * test)
(take 3 results))

({:id 1, :age 224} {:id 2, :age 23} {:id 3, :age 402})

If you run into trouble, because somethings is not currently
implemented, you can always resort to using (raw "SELECT * FROM foo
USING SPECIAL FUNC") or something similar - So you wont be stuck. If
you come across some features that are lacking, bugs that need
reporting or similar, please drop us a message at IRC or Github,
you'll find the project here: http://github.com/Lau-of-DK/clojureql/tree/master

Expect Join/Run syntax to change in the near future, and dont be
surprised if you come across something that needs a patch - We're not
1.0 yet, and we could use a little help in getting there :)

/Lau

Ozzi Lee

unread,
Jul 2, 2009, 11:16:30 AM7/2/09
to Clojure
I get an error when compiling from head with ant. It dies with:

java.lang.ClassNotFoundException: org.mysql.jdbc.Connection (mysql.clj:
18)

Meikel Brandmeyer

unread,
Jul 2, 2009, 11:43:27 AM7/2/09
to clo...@googlegroups.com
Hi,

You'll need the JDBC drivers for MySQL and Derby. Otherwise
the corresponding backends won't compile. If you use Ivy (just
don't put the "clojure.jar = .." line into local.properties), it will
download the dependencies for you.

Sincerely
Meikel

Ozzi Lee

unread,
Jul 2, 2009, 2:44:50 PM7/2/09
to Clojure
It looks like ant is using ivy to get these dependencies, unless I'm
reading it wrong.

Is this what I need?
http://dev.mysql.com/downloads/connector/j/3.1.html

$ ant

Buildfile: build.xml

init:

download-ivy:
[get] Getting: http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.1.0-rc1/ivy-2.1.0-rc1.jar
[get] To: /home/nroling/repos/clojureql/lib/ivy.jar
[get] Not modified - so not downloaded

install-ivy:

resolve:
No ivy:settings found for the default reference 'ivy.instance'. A
default instance will be used
[ivy:resolve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/
::
:: loading settings :: file = /home/nroling/repos/clojureql/
ivysettings.xml
[ivy:resolve] :: resolving dependencies ::
dk.bestinclass#clojureql;working@nroling-desktop
[ivy:resolve] confs: [source, compiled, derby, mysql, default]
[ivy:resolve] found org.clojure#clojure;1.0.0 in KotkaRepo
[ivy:resolve] found org.apache.derby#derby;10.4.2.0 in public
[ivy:resolve] found mysql#mysql-connector-java;5.1.6 in public
[ivy:resolve] :: resolution report :: resolve 155ms :: artifacts dl
8ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| source | 1 | 0 | 0 | 0 || 1 | 0 |
| compiled | 1 | 0 | 0 | 0 || 1 | 0 |
| derby | 1 | 0 | 0 | 0 || 1 | 0 |
| mysql | 1 | 0 | 0 | 0 || 1 | 0 |
| default | 1 | 0 | 0 | 0 || 2 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: dk.bestinclass#clojureql
[ivy:retrieve] confs: [source, compiled, derby, mysql, default]
[ivy:retrieve] 0 artifacts copied, 6 already retrieved (0kB/15ms)

aot:
[java] Compiling dk.bestinclass.clojureql.util to /home/nroling/
repos/clojureql/classes
[java] Compiling dk.bestinclass.clojureql to /home/nroling/repos/
clojureql/classes
[java] Compiling dk.bestinclass.clojureql.backend.derby to /home/
nroling/repos/clojureql/classes
[java] Compiling dk.bestinclass.clojureql.backend.mysql to /home/
nroling/repos/clojureql/classes

BUILD FAILED
java.lang.ClassNotFoundException: org.mysql.jdbc.Connection (mysql.clj:
18)
at clojure.lang.Compiler.analyze(Compiler.java:4340)
at clojure.lang.Compiler.analyze(Compiler.java:4286)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2771)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4498)
at clojure.lang.Compiler.analyze(Compiler.java:4325)
at clojure.lang.Compiler.analyze(Compiler.java:4286)
at clojure.lang.Compiler.compile(Compiler.java:4948)
at clojure.lang.RT.compile(RT.java:354)
at clojure.lang.RT.load(RT.java:393)
at clojure.lang.RT.load(RT.java:367)
at clojure.core$load__5058$fn__5061.invoke(core.clj:3734)
at clojure.core$load__5058.doInvoke(core.clj:3733)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.core$load_one__5010.invoke(core.clj:3578)
at clojure.core$compile__5065$fn__5067.invoke(core.clj:3744)
at clojure.core$compile__5065.invoke(core.clj:3743)
at clojure.lang.Var.invoke(Var.java:346)
at clojure.lang.Compile.main(Compile.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:
217)
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:
152)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:764)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:
288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute
(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:
1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets
(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.lang.ClassNotFoundException: org.mysql.jdbc.Connection
at org.apache.tools.ant.AntClassLoader.findClassInComponents
(AntClassLoader.java:1400)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:
1341)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:
1094)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.classForName(RT.java:1487)
at clojure.lang.Compiler.resolveIn(Compiler.java:4665)
at clojure.lang.Compiler.resolve(Compiler.java:4628)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:4605)
at clojure.lang.Compiler.analyze(Compiler.java:4307)
... 43 more

Total time: 3 seconds

Meikel Brandmeyer

unread,
Jul 2, 2009, 4:21:15 PM7/2/09
to clo...@googlegroups.com
Hi,

geez. A Schrödingbug.... I know I compiled it before, but
after a clean it broke. :( I'll see how to fix it.

Sincerely
Meikel

Meikel Brandmeyer

unread,
Jul 2, 2009, 4:26:10 PM7/2/09
to clo...@googlegroups.com
Hi,

ok. Fixed it. Was a stupid typo in the classname. Obviously it was no
Schrödingbug, since I didn't compile the changes....

Fix is up on github.

Sincerely
Meikel

Ozzi Lee

unread,
Jul 2, 2009, 4:36:59 PM7/2/09
to Clojure
BUILD SUCCESSFUL
Total time: 6 seconds

Awesome, thanks for the quick fix!
Reply all
Reply to author
Forward
0 new messages