Nick Sieger: ActiveRecord JDBC 0.5tag:blog.nicksieger.com,2005:TypoTypo2007-09-03T03:24:16+00:00Jon Tirsenurn:uuid:13bad3ea-70b1-46e9-8c1e-a55b508b75372007-09-03T03:24:16+00:002007-09-03T03:24:16+00:00Comment on ActiveRecord JDBC 0.5 by Jon Tirsen<p>Don’t forget you need to require the jar files for each database you need to use.</p>Nick Siegerurn:uuid:ed536239-db15-4a7d-963b-469c4b020d8f2007-09-02T04:47:26+00:002007-09-02T04:47:26+00:00ActiveRecord JDBC 0.5<p>This one’s a bit late – consider it part of my <a href="/articles/2007/07/13/pause">get-caught-up-since-unclogging-the-clogged-blog</a> series.</p>
<p>ActiveRecord JDBC 0.5 is out, so you may have heard (it went out the door a week ago Friday; c.f.
<a href="http://blogs.sun.com/arungupta/entry/activerecord_jdbc_0_5_simplified">Arun</a> and <a href="http://www.bloglines.com/blog/ThomasEEnebo?id=36">Tom</a>). The major feature you get in this version is a new <code>database.yml</code>
configuration style:</p>
<div class="typocode"><pre><code class="typocode_default ">development:
adapter: mysql
database: blog_development
username: root
password:</code></pre></div>
<p>Ok, ok, so what’s the big deal? This is just Rails’ default database configuration. Well, that’s the
point – you no longer have to know anything about JDBC URLs, driver class names, and all that. We’ve baked it in for you. This should make it easier than ever to try out your Rails application on JRuby, as the only piece of manual configuration left for you is the ugly bit of JRuby-specific code you need to <a href="http://www.headius.com/jrubywiki/index.php/Running_Rails_with_ActiveRecord-JDBC">activate ActiveRecord-JDBC</a> lurking right above the <code>Rails::Initializer</code>:</p>
<div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">if</span> <span class="constant">RUBY_PLATFORM</span> <span class="punct">=~</span> <span class="punct">/</span><span class="regex">java</span><span class="punct">/</span>
<span class="ident">require</span> <span class="punct">'</span><span class="string">rubygems</span><span class="punct">'</span>
<span class="ident">gem</span> <span class="punct">'</span><span class="string">ActiveRecord-JDBC</span><span class="punct">'</span>
<span class="ident">require</span> <span class="punct">'</span><span class="string">jdbc_adapter</span><span class="punct">'</span>
<span class="keyword">end</span></code></pre></div>
<p>If we can obliterate the need for this last bit of code, and make it easy to obtain the necessary driver bits, I’ll feel good enough to call this thing a 1.0 product.</p>