Attempting to use JRuby 1.2.0 and Rails 2.3.2 with an embedded Derby database. I've copied derbytools.jar
and derby.jar
to $RUBY_HOME/lib
, yet rake db:migrate
still gives:
The driver encountered an error:
cannot load Java class org.apache.derby.jdbc.ClientDriver
Aaaand... I played a hunch and figured it out. So, I'll post this here in case somebody else runs into the same problem I did.
Almost all the documentation I found online has the following database.yml
configuration for Derby:
development:
adapter: jdbc
driver: org.apache.derby.jdbc.ClientDriver
url: jdbc:derby:[db];create=true
username: xxx
password: xxx
This probably works fine for a client/server setup, but for an embedded Derby setup, you need this:
development:
adapter: jdbc
driver: org.apache.derby.jdbc.EmbeddedDriver
url: jdbc:derby:[db];create=true
username: xxx
password: xxx
Note the 'EmbeddedDriver', and not 'ClientDriver'.
Going to answer, because I hate seeing that red block in my profile.
There's also a subtle bug in ActiveRecord-JDBC when you use embedded derby -- if you don't give it a username and a password, nothing works. I've tracked down the cause of this bug, and am working on submitting a patch, but if you run into the same problem I did, let me know, and I'll post the code here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With