Using pg and mysql gems on jruby-head?

I filed Missing Time.to_date? · Issue #214 · jruby/jruby · GitHub. enebo said, “Try
jruby-1.7.0.pre1”. Okay. I am looking to see if jruby is faster for my
CPU-bound long-running process (15 minutes for the short version).

I installed Java 7. I did “rvm install jruby-head”. I tried “bundle” to
install my gems, and it barfed on “mysql” and “pg” (at least) because
they
are native extensions, even after I threw caution to the wind and put
“cext.enabled=true” in my .jrubyrc. However, I need to access postgres
and
mysql. Google revealed sometimes there are alternative gems for jruby,
also
suggested plans for supporting native extensions in newer versions of
jruby, but I can’t find details on either.

What is the state of this? Can I install pg and mysql gems somehow, must
I
abandon attempts at jruby, or is there hidden option c? Please don’t ask
me
to significantly rewrite my source tree (e.g., change require
statements),
especially if it leaves it ruby-incompatible.

Thanks for your attention.

Oh, the detailed error message:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

    /Users/me/.rvm/rubies/jruby-head/bin/jruby extconf.rb

/Users/me/.rvm/rubies/jruby-head/lib/ruby/shared/mkmf.rb:14: Use
RbConfig
instead of obsolete and deprecated Config.
mkmf.rb can’t find header files for ruby at
/Users/me/.rvm/rubies/jruby-head/lib/native/include/ruby/ruby.h

You need to use the jdbc adapters when using jruby:

I typically use “pure java” gems or wrap JDBC myself.
For rails it doesn’t require “much” code change:

YMMV

Thanks for your suggestions.

I am using the ‘sequel’ gem. says:
GitHub - jruby/activerecord-jdbc-adapter: JRuby's ActiveRecord adapter using JDBC. “Legacy
configuration:
If you use one of the convenience activerecord-jdbcXXX-adapter adapters,
you can still put a jdbc prefix in front of the database adapter name as
below.”

$ gem install activerecord-jdbcpostgresql-adapter
Fetching: activerecord-jdbc-adapter-1.2.2.gem (100%)
Fetching: jdbc-postgres-9.1.901.gem (100%)
Fetching: activerecord-jdbcpostgresql-adapter-1.2.2.gem (100%)
Successfully installed activerecord-jdbc-adapter-1.2.2
Successfully installed jdbc-postgres-9.1.901
Successfully installed activerecord-jdbcpostgresql-adapter-1.2.2
3 gems installed

Tried adapter of “jdbcpostgresql”. I get:

Sequel::AdapterNotFound: LoadError: no such file to load –
sequel/adapters/jdbcpostgresql
chained_4_rescue_line_25 at
/Users/me/.rvm/gems/jruby-head/gems/sequel-3.36.1/lib/sequel/database/connecting.rb:27

Looked in dir:

$ ls
/Users/me/.rvm/gems/jruby-head/gems/sequel-3.36.1/lib/sequel/adapters/jdbc/postgresql.rb
/Users/me/.rvm/gems/jruby-head/gems/sequel-3.36.1/lib/sequel/adapters/jdbc/postgresql.rb

So how do I choose the right adapter for sequel?

Thanks for your attention.

Although technically you are correct (this is about using sequel), it is
a
barrier to using jruby. I would think if the jruby community wants to
support users, it would be good to have a ready answer to what seems a
common question to me.

Hi Dan

You should be asking this question on the Sequel Google group
https://groups.google.com/forum/?fromgroups#!forum/sequel-talk

Since you are using Sequel and not AR you need to install the
jdbc-postgres
gem, I would uninstall activerecord-jdbcpostgresql-adapter first. The
uri
should be of the form jdbc:postgresql:///. More details
here
http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html

Rohit

Also, I am not using a URI. As stated, I am using an adapter, i.e.
Sequel.connect with :host, :database, :user, :port, :adapter parameters.

The advantage of using a uri is that you can append any connection
specific
options supported by the postgres jdbc driver to the uri string.

Sequel.connect(:adapter => ‘jdbc’,
:username => ‘xxx’,
:password => ‘xxx’,
:uri => ‘jdbc:postgresql://localhost;database=xyz’)