Path: | README.txt |
Last Update: | Sat Oct 25 23:22:17 +0000 2008 |
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.
To use ActiveRecord-JDBC with JRuby on Rails:
* base jdbc (<tt>activerecord-jdbc-adapter</tt>). Supports all available databases via JDBC, but requires you to download and manually install the database vendor's JDBC driver .jar file. * mysql (<tt>activerecord-jdbcmysql-adapter</tt>) * postgresql (<tt>activerecord-jdbcpostgresql-adapter</tt>) * derby (<tt>activerecord-jdbcderby-adapter</tt>) * hsqldb (<tt>activerecord-jdbchsqldb-adapter</tt>) * h2 (<tt>activerecord-jdbch2-adapter</tt>)
if RUBY_PLATFORM =~ /java/ require 'rubygems' gem 'activerecord-jdbc-adapter' require 'jdbc_adapter' end
For mysql, postgres, derby, oracle, hsqldb and h2 you can simply configure the database in the normal Rails style. If you use one of the convenience ‘activerecord-jdbcXXX-adapter’ adapters, be sure and put a ‘jdbc’ prefix in front of the databas adapter name as below.
development: adapter: jdbcmysql username: blog password: hostname: localhost database: weblog_development
For other databases, you‘ll need to know the database driver class and URL. Example:
development: adapter: jdbc username: blog password: driver: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/weblog_development
jruby -S gem install activerecord-jdbc-adapter
If you wish to use the adapter for a specific database, you can install it directly and a driver gem will be installed as well:
jruby -S gem install activerecord-jdbcderby-adapter
require 'rubygems' gem 'activerecord-jdbc-adapter' require 'jdbc_adapter' require 'active_record'
ActiveRecord::Base.establish_connection( :adapter => 'jdbcderby', :database => "db/my-database" )
or like this (but requires that you manually put the driver jar on the classpath):
ActiveRecord::Base.establish_connection( :adapter => 'jdbc', :driver => 'org.apache.derby.jdbc.EmbeddedDriver', :url => 'jdbc:derby:test_ar;create=true' )
Drivers for 4 open-source databases are included. Provided you have MySQL installed, you can simply type jruby -S rake to run the tests. A database named weblog_development is needed beforehand with a connection user of "blog" and password empty.
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.
Open-source driver gems for ActiveRecord JDBC are licensed under the same license the database‘s drivers are licensed. See each driver gem‘s LICENSE.txt file for details.