Forum: JRuby JDBC connection from Java to jRuby on Rails

E413e67f84dd83d35973e4251790bd8c?d=identicon&s=25 Chason Choate (Guest)
on 2014-07-31 00:01
(Received via mailing list)
Hello all,

I have a question regarding JDBC connections between Java and jRuby on
Rails.

Environment:

Centos 6.5
Java 7
jRuby on Rails 4.1
activerecord-jdbc-adapter

At my company we are a Java shop. We have recently starting using jRuby
(which is awesome) and jRuby on Rails for web development. The Java app
will boot up rails via the rack-servlet (
https://github.com/square/rack-servlet) which looks for a config.ru
file.
Once that happens the Rails app will call back to the Java app for it's
DB
type and java.sql.datasource object. At this point how do I configure
ActiveRecord to use the passed java.sql.datasource object?

Thanks for your time, and if you need me to clarify anything please let
me
know.
Caa2df9372ffa0a9e95b2bab1e8fea34?d=identicon&s=25 Karol Bucek (Guest)
on 2014-07-31 06:20
(Received via mailing list)
Hey! ... if you establish the connection "by hand" ... than simply:
ActiveRecord::Base.establish_connection :adapter => 'mysql',
:data_source
=> data_source_object

The usual case is to configure the JNDI name (for a bound data-source)
in
database.yml ... one again :

  adapter: 'mysql'
  jndi: java:comp/env/jdbc/MyDS

Cheers, K.

On Wed, Jul 30, 2014 at 11:59 PM, Chason Choate <
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.