Check out how the activerecord-jdbc-adapters work: https://github.com/jruby/activerecord-jdbc-adapter