title: Access java.sql.connection from ActiveRecord JRuby?
body: <p>I am using Jruby and Rails 3 with <a href="http://jxls.sourceforge.net/reference/sqlreporting.html" rel="nofollow">jxls</a>, a Java library to generate reports in Excel.</p>
  
  <p>The jxls API has a ReportManagerImpl which takes a java.sql.Connection in its constructor.</p>
  
  <pre><code>ReportManager reportManager = new ReportManagerImpl( conn, beans );
  </code></pre>
  
  <p>In my non-working code, ReportQuery is a ActiveRecord object. The Jruby looks like this:</p>
  
  <pre><code>conn = ReportQuery.connection
  rm = Java::NetSfJxlsReport::ReportManagerImpl.new(conn, params)
  </code></pre>
  
  <p>But ActiveRecord::Base.connection returns not a java.sql.Connection, but a ActiveRecord::ConnectionAdapters::JdbcAdapter.</p>
  
  <p><strong>How can I access the underlying java.sql.Connection object from JRuby?</strong></p>
  
  <p>The error message I get is:</p>
  
  <pre><code>2012-12-28 17:28:08,000 [main] WARN org.apache.commons.jexl2.JexlEngine - ![3,149]: 'rm.exec('SELECT d.name depname, e.name empname, age, payment, bonus, birthDate FROM employee e, department d where d.id = e.depid order by age desc');' method invocation error org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `createStatement' for #&lt;ActiveRecord::ConnectionAdapters::JdbcAdapter:0x13ba673&gt; 
  </code></pre>