can't connect to Derby DB; "No suitable driver found" error message

408 views
Skip to first unread message

Gregg Williams

unread,
Apr 26, 2012, 2:33:02 AM4/26/12
to clj-record-dev
I have Derby installed on my Mac OS 10.6 machine. It seems to be
installed correctly, because I can do this:

---
22:46 clj-record $ij
ij version 10.8
ij> CONNECT 'jdbc:derby:firstdb;create=true';
ij> CREATE TABLE FIRSTTABLE
(ID INT PRIMARY KEY,
NAME VARCHAR(12));> >
0 rows inserted/updated/deleted
ij> INSERT INTO FIRSTTABLE VALUES
(10,'TEN'),(20,'TWENTY'),(30,'THIRTY');> >

3 rows inserted/updated/deleted
ij> SELECT * FROM FIRSTTABLE;
ID |NAME
------------------------
10 |TEN
20 |TWENTY
30 |THIRTY

3 rows selected
ij>
---

I uncommented the Derby-related code in test_model/config.clj,
commented out the mysql code, and ran `lein deps`.

When I attempted to reset the test database manually, I got a "No
suitable driver found" error, as shown in the following:

---
23:09 clj-record $lein repl
REPL started; server listening on localhost port 49388
user=> (require 'clj-record.test-helper)
nil
user=> (clj-record.test-helper/reset-db)
resetting derby
SQLException No suitable driver found for jdbc:derby:/tmp/clj-
record.test.db java.sql.DriverManager.getConnection
(DriverManager.java:602)
user=>
---

I've read a lot of pages connected to http://db.apache.org/derby/docs/dev/getstart/,
and I'm very confused.

The page http://db.apache.org/derby/papers/DerbyClientSpec.html#Client+CLASSPATH
talks about adding derby.jar and derbyclient.jar to the Java
CLASSPATH, which sounds reasonable.

Any ideas on what I need to do to make (clj-record.test-helper/reset-
db) run? Thanks.

Gregg Williams

unread,
Apr 26, 2012, 2:56:38 AM4/26/12
to clj-rec...@googlegroups.com
As so often occurs, I thought of something *after* I posted: I copied derby.jar and derbyclient.jar into the clj-record/lib directory, tried everything again, and got `lein test` to run with no errors. Thanks for listening!

John D. Hume

unread,
Apr 26, 2012, 8:00:00 AM4/26/12
to clj-rec...@googlegroups.com
You could also have changed project.clj to point at
[org.apache.derby/derby "10.8.2.2"] (or whatever version you prefer)
instead of the MySQL driver. (You can find that and any other java jar
published for maven here:
http://search.maven.org/#artifactdetails%7Corg.apache.derby%7Cderby%7C10.8.2.2%7Cjar)

Note that what you're doing now is valuable to make sure clj-record's
tests still pass with Derby, but when you want to use clj-record in
your project, you just need to install clj-record and whatever driver
you want to use as dependencies of your project (as shown here
https://clojars.org/clj-record) and set up your own "db spec" with
your driver of choice. No modifications to clj-record itself should be
necessary.

-hume.
--
http://elhumidor.blogspot.com/
http://www.intentmedia.com/jobs
Reply all
Reply to author
Forward
0 new messages