| Path: | README.txt |
| Last Update: | Mon Mar 05 19:35:17 -0800 2007 |
ActiveRecord-JDBC is a database adapter for Rails’ ActiveRecord component that can be used with JRuby. It allows use of virtually any JDBC-compliant database with your JRuby on Rails application.
ActiveRecord JDBC is a sub-project of jruby-extras at RubyForge.
What‘s there, and what is not there:
Other databases will require testing and likely a custom configuration module. Please join the jruby-extras mailing-list to help us discover support for more databases.
jruby --command gem install ActiveRecord-JDBC
require 'rubygems' gem 'ActiveRecord-JDBC' require 'jdbc_adapter' require 'active_record'
ActiveRecord::Base.establish_connection( :adapter => 'jdbc', :driver => 'org.apache.derby.jdbc.EmbeddedDriver', :url => 'jdbc:derby:test_ar;create=true' )
Provided you have the derby libraries in your classpath, this is enough to establish an in-memory JDBC connection. The required parameters to establish_connection for ActiveRecord JDBC are:
If provided, password and username will be used. After the connection is established Active Record can be used as usual.
To use ActiveRecord-JDBC with JRuby on Rails:
jruby --command gem install ActiveRecord-JDBC
require 'rubygems' gem 'ActiveRecord-JDBC' require 'jdbc_adapter'
development: adapter: jdbc username: blog password: driver: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/weblog_development
By default hsql, mysql, and derby are run. In order to run all tests you must download each of the databases about put their JDBC drivers in your classpath. Here is an example of I use:
CLASSPATH=~/opt/derby/lib/derby.jar:~/opt/mysql/mysql-connector-java-3.1.14-bin.jar:~/opt/hsqldb/lib/hsqldb.jar jruby ../jruby/bin/jruby --command rake
This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini <ola@ologix.com> with lots of help from the JRuby community.
ActiveRecord-JDBC is released under a BSD license. See the LICENSE file included with the distribution for details.