A JRuby version of the "pg" gem.
Java C Ruby Shell
Switch branches/tags
Nothing to show
Failed to load latest commit information.
certs Add support for JRuby Feb 21, 2015
ext Use proper way to get a RubyEncoding object from JRuby. May 9, 2017
lib Tweaks to get a jruby-pg gem releasable. May 9, 2017
misc Update windows cross compilation tasks to the latest Openssl+Postgres… Jun 17, 2012
sample Whitespace cleanup Mar 26, 2013
spec try to make travis ci green Feb 27, 2015
.gemtest Converted to Hoe Oct 7, 2011
.gitignore add the jar file to the repo so users can use bundler :git => ... Jul 22, 2015
.hgignore Add generated error codes file to the ignorelist Jul 17, 2013
.hgsigs Added signature for changeset 22d57e3a2b37 Dec 19, 2013
.hgtags Added tag v0.17.0 for changeset 30da9c169efc Sep 16, 2013
.hoerc Add the Gemfile to the list of files that don't have to be on the Man… Sep 16, 2013
.irbrc Updated build system Jan 3, 2010
.pryrc Rearranging classes under the PG namespace to be a better Ruby citizen Jan 25, 2012
.tm_properties Fix indent in project settings Jun 7, 2013
.travis.yml simplify our test matrix for now Feb 22, 2015
BSDL Add missing BSDL license file (fixes #108) Feb 9, 2012
Contributors.rdoc Update the docs Feb 22, 2015
Gemfile Add Gemfile for compat with rake-compiler-dev-box. Aug 14, 2013
History.rdoc Bump the patch version, set the date in History. Dec 19, 2013
LICENSE Updated/simplified authors/license sections of the README, API doc cl… Jan 25, 2012
Manifest.txt Tweaks to get a jruby-pg gem releasable. May 9, 2017
POSTGRES fix cross compilation of win32 binary gem, fix mixed case file naming Jan 27, 2012
README-OS_X.rdoc More case-corrections Jan 27, 2012
README-Windows.rdoc More case-corrections Jan 27, 2012
README.ja.rdoc Update READMEs Feb 27, 2013
README.rdoc Adds a link to sample rails app Feb 6, 2016
Rakefile Tweaks to get a jruby-pg gem releasable. May 9, 2017
Rakefile.cross Use RbConfig::CONFIG['CC'] instead of ['host'] for determining cross Aug 15, 2013
TODO.md add a TODO Feb 22, 2015
test_all.sh add a script that supports tesitng with rails Feb 21, 2015



This is a JRuby gem replacement for ruby-pg. The gem should be a drop-in replacement for ruby-pg version 0.17.1. If you see any inconsistency please open an issue here.

Another JRuby Postgres adapter is jdbc-postgres. jruby-pg provides a few interfaces that jdbc-postgres doesn't have. Most use cases don't require those interfaces, specially if you are using ActiveRecord. Extra APIs in the pg & jruby-pg gem include:

  • Async API for querying

  • Large objects API

  • Bulk Copy API

  • Notification API


For documentation please refair to the MRI pg gem docs which you can find here. The original ruby-pg project can be found here on github.

Build Status



The gem has been tested with the following:

  • JRuby 1.7.18

  • PostgreSQL 9.3.6

It may work with earlier versions of Ruby/PostgreSQL as well, but those are not regularly tested.

How To Install

NOTE: if you are installing jruby-pg to use it with rails you'll have to install it using bundler.

Install via RubyGems:

gem install pg_jruby

Install via Bundler, in your gemfile add the following:

# Please note that Bundler version 1.0 is necessary to let bundler do its dependency management,
# as there is no .gemspec in the source.
gem 'pg', '0.17.1', :platform => :jruby, :git => 'git://github.com/headius/jruby-pg.git', :branch => :master

# comment the activerecord-jdbcsqlite3-adapter line
# gem 'activerecord-jdbcsqlite3-adapter'

Sample app

See this app for a demonstration of using jruby-pg with rails


Copyright © 1997-2013 by the authors.

MRI contributors

  • Jeff Davis <ruby-pg@j-davis.com>

  • Guy Decoux (ts) <decoux@moulon.inra.fr>

  • Michael Granger <ged@FaerieMUD.org>

  • Lars Kanis <lars@greiz-reinsdorf.de>

  • Dave Lee

  • Eiji Matsumoto <usagi@ruby.club.or.jp>

  • Yukihiro Matsumoto <matz@ruby-lang.org>

  • Noboru Saitou <noborus@netlab.jp>

JRuby contributors

  • John Shahid <jvshahid@gmail.com>

You may redistribute this software under the same terms as Ruby itself; see www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source for details.

Portions of the code are from the PostgreSQL project, and are distributed under the terms of the PostgreSQL license, included in the file POSTGRES.

Portions copyright LAIKA, Inc.


See Contributors.rdoc for the many additional fine people that have contributed to this library over the years.

We are thankful to the people at the ruby-list and ruby-dev mailing lists. And to the people who developed PostgreSQL.