ActiveRecord adapter using JDBC for JRuby. Please, support the project at BountySource's
Ruby Java
Switch branches/tags
Pull request Compare This branch is even with jruby:master.
Failed to load latest commit information.
activerecord-jdbcderby-adapter boost an ego - standing on the shoulders of AR-JDBC giants + spec lic… Jan 9, 2014
activerecord-jdbch2-adapter [h2] allow jdbch2 adapter to use jdbc-h2 1.4 (fixes #639) Apr 13, 2015
activerecord-jdbchsqldb-adapter boost an ego - standing on the shoulders of AR-JDBC giants + spec lic… Jan 9, 2014
activerecord-jdbcmssql-adapter boost an ego - standing on the shoulders of AR-JDBC giants + spec lic… Jan 9, 2014
activerecord-jdbcmysql-adapter [mysql] strict JDBC driver selector - we do not know about next versions Nov 12, 2017
activerecord-jdbcpostgresql-adapter [postgres] only support recent-ish PG driver 9.4.x / 42.y.z Nov 12, 2017
activerecord-jdbcsqlite3-adapter [sqlite3] include a more recent JDBC driver version (+ latest 3.20 is… Nov 12, 2017
bench delete benchmarks and bench/results sub-report Jun 30, 2015
jdbc-derby make sure *gem.homepage* is "easier" to locate for some Jul 14, 2014
jdbc-firebird make sure *gem.homepage* is "easier" to locate for some Jul 14, 2014
jdbc-h2 Update Gem Homepage Nov 7, 2016
jdbc-hsqldb make sure *gem.homepage* is "easier" to locate for some Jul 14, 2014
jdbc-jtds better jdbc- gem summaries + READMEs Jun 18, 2014
jdbc-mariadb make sure *gem.homepage* is "easier" to locate for some Jul 14, 2014
jdbc-mysql [refactor] follow same convention as released jdbc-mysql gem Nov 9, 2017
jdbc-postgres Remove old postgres driver jars Nov 13, 2017
jdbc-sqlite3 match (released) jdbc-sqlite3 3.20.1 gem version on this branch Nov 9, 2017
lib Merge branch '50-stable' : Nov 20, 2017
rails_generators update jdbc generator - add a few notes that it is only needed on Rai… May 25, 2013
rakelib Merge branch '50-stable' Nov 20, 2017
src/java/arjdbc Hmm looks like we had an errant import to old postgresql jdbc jar? Nov 13, 2017
test Merge branch '50-stable' Nov 20, 2017
.gitignore Add ignore to idea file turd Nov 7, 2017
.travis.yml [travis-ci] this branch targets AR 5.1 thus checkout Rails repo at v5… Nov 20, 2017
.yardopts update rake + setup yard Jun 27, 2013 update README (for 1.3.0 stable) Aug 29, 2013
Gemfile use v5.0.6 for Rails repo checkout, for now (5-0-stable isn't that st… Nov 20, 2017 prepare for 1.3.20 Mar 9, 2016
LICENSE.txt "new" recommended jndi: adapter configuration for less confusion + (c… Jan 9, 2014 Update README some more Nov 13, 2017 Removed appraisal gem and updated gemspec/gemfile to require activere… Nov 2, 2017
Rakefile Remove all not planned adapters from our rake targets Nov 10, 2017
Rakefile.jdbc share the Rakefile for jdbc gems Jun 18, 2013
activerecord-jdbc-adapter.gemspec [fix] limit activerecord to 5.1.x for AR-JDBC 51.x Nov 15, 2017
activerecord-jdbc.iml Bump Java version to 1.7. Nov 7, 2017
pom.xml Bump Java version to 1.7. Nov 7, 2017

ActiveRecord JDBC Adapter

Gem Version

ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails' ActiveRecord component that can be used with JRuby. ActiveRecord-JDBC-Adapter provides full or nearly full support for: MySQL, PostgreSQL, SQLite3. In the near future there are plans to add support MSSQL. Unless we get more contributions we will not be going beyond these four adapters. Note that the amount of work needed to get another adapter is not huge but the amount of testing required to make sure that adapter continues to work is not something we can do with the resources we currently have.

For Oracle database users you are encouraged to use

Version 50.x supports Rails version 5.0.x and it lives on branch 50-stable. Version 51.x supports Rails version 5.1.x and is currently on master until its first release. The minimum version of JRuby for 50+ is JRuby 9.1.x and JRuby 9.1+ requires Java 7 or newer.

Using ActiveRecord JDBC

Inside Rails

To use AR-JDBC with JRuby on Rails:

  1. Choose the adapter you wish to gem install. The following pre-packaged adapters are available:
  • MySQL (activerecord-jdbcmysql-adapter)
  • PostgreSQL (activerecord-jdbcpostgresql-adapter)
  • SQLite3 (activerecord-jdbcsqlite3-adapter)
  1. If you're generating a new Rails application, use the following command:

    jruby -S rails new sweetapp

  2. Configure your database.yml in the normal Rails style:

  adapter: mysql2 # or mysql
  database: blog_development
  username: blog
  password: 1234

For JNDI data sources, you may simply specify the JNDI location as follows, it's recommended to use the same adapter: setting as one would configure when using "bare" (JDBC) connections e.g. :

  adapter: postgresql
  jndi: jdbc/PostgreDS

NOTE: any other settings such as database:, username:, properties: make no difference since everything is already configured on the JNDI DataSource end.

JDBC driver specific properties might be set if you use an URL to specify the DB or preferably using the properties: syntax:

  adapter: mysql
  username: blog
  password: blog
  url: "jdbc:mysql://localhost:3306/blog?profileSQL=true"
  properties: # specific to com.mysql.jdbc.Driver
    socketTimeout:  60000
    connectTimeout: 60000

Standalone with ActiveRecord

Once the setup is made (see below) you can establish a JDBC connection like this (e.g. for activerecord-jdbcderby-adapter):

  adapter: 'sqlite3',
  database: 'db/my-database'

Using Bundler

Proceed as with Rails; specify ActiveRecord in your Bundle along with the chosen JDBC adapter(s), this time sample Gemfile for MySQL:

gem 'activerecord', '~> 5.0.6'
gem 'activerecord-jdbcmysql-adapter', :platform => :jruby

When you require 'bundler/setup' everything will be set up for you as expected.

Without Bundler

Install the needed gems with JRuby, for example:

gem install activerecord -v "~> 5.0.6"
gem install activerecord-jdbc-adapter --ignore-dependencies

If you wish to use the adapter for a specific database, you can install it directly and the (jdbc-) driver gem (dependency) will be installed as well:

jruby -S gem install activerecord-jdbcmysql-adapter

Your program should include:

require 'active_record'
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
# or in case you're using the pre-packaged adapter gem :
require 'activerecord-jdbcmysql-adapter' if defined? JRUBY_VERSION


The source for activerecord-jdbc-adapter is available using git:

git clone git://

Please note that the project manages multiple gems from a single repository, if you're using Bundler >= 1.2 it should be able to locate all gemspecs from the git repository. Sample Gemfile for running with (MySQL) master:

gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter', :github => 'jruby/activerecord-jdbc-adapter'

Getting Involved

Please read our CONTRIBUTING & RUNNING_TESTS guides for starters. You can always help us by maintaining AR-JDBC's wiki.


Please report bugs at our issue tracker. If you're not sure if something's a bug, feel free to pre-report it on the mailing lists or ask on the #JRuby IRC channel on (try web-chat).


This project was originally written by Nick Sieger and Ola Bini with lots of help from the JRuby community. Polished 3.x compatibility and 4.x support (for AR-JDBC >= 1.3.0) was managed by Karol Bucek among others.


ActiveRecord-JDBC-Adapter is open-source released under the BSD/MIT license. See LICENSE.txt included with the distribution for details.

Open-source driver gems within AR-JDBC's sources are licensed under the same license the database's drivers are licensed. See each driver gem's LICENSE.txt.