Nick Sieger: ActiveRecord-JDBC 0.6 Released! tag:blog.nicksieger.com,2005:Typo Typo 2010-11-22T19:41:06+00:00 Nick urn:uuid:10e3f83c-92f3-49e9-a5f3-94cffec304b5 2007-11-19T15:37:42+00:00 2010-11-22T19:41:06+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Nick <p>@Tom: Yes, that&#8217;s correct, because Oracle&#8217;s driver is proprietary&#46; You use the activerecord&#45;jdbc&#45;adapter gem only, with the standard configuration&#46; See the <a href='http://jruby-extras.rubyforge.org/activrecord-jdbc-adapter' rel="nofollow">documentation</a> for details&#46;</p> Tom urn:uuid:d1ca86d5-3cea-4928-ae6d-10b3eb3a8d3d 2007-11-19T11:50:45+00:00 2010-11-22T19:41:06+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Tom <p>How do you configure it for Oracle? There is no activerecord&#45;oracle&#45;adapter gem&#46;</p> Nick urn:uuid:fc17e368-77ad-49e7-96cd-0d2ab555c06a 2007-11-07T20:26:35+00:00 2010-11-22T19:41:06+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Nick <p>@François: yes, unfortunately we have the embedded derby URL hard&#45;coded in the jdbc_derby&#46;rb file in the activerecord&#45;jdbc&#45;adapter codebase, so you&#8217;ll have to use the url/driver properties in your database&#46;yml&#46; But you still should be able to use adapter == &#8216;jdbcderby&#8217;&#46;</p> Francois Orsini urn:uuid:ca96ddc0-34c8-4d56-a7b8-738b3e73bd3e 2007-11-07T19:48:56+00:00 2010-11-22T19:41:07+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Francois Orsini <p>This is great stuffs Nick&#46; Forgive my naive question but if I want to connect to a remote Derby instance (not an embedded one), I would still need to use the straight activerecord&#45;jdbc&#45;adapter and set the appropriate settings (driver class &amp; connection URL) as well as placing the derbyclient&#46;jar in that case in some appropriate location&#46;&#46;&#46; The activerecord&#45;jdbcderby&#45;adapter is only to connect to a embedded Derby instance, right? Cheers&#46;</p> Oliver Schmelzle urn:uuid:ad4c9c63-31c7-438b-9104-04d0b2ec74e6 2007-11-07T19:44:34+00:00 2010-11-22T19:41:07+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Oliver Schmelzle <p>Thanks for releasing this new version&#46;</p> <p>When using Radiant 0&#46;6&#46;3 with ActiveRecord&#45;JDBC 0&#46;6 I noticed migrations were failing due to a problem with renaming column names&#46;</p> <p>I filed a bug and fix for this issue at:</p> <p><a href='http://jira' rel="nofollow">http://jira</a>&#46;codehaus&#46;org/browse/JRUBY&#45;1543</p> Nick urn:uuid:c4744472-2fee-431d-bd60-059bbc161413 2007-11-07T18:09:06+00:00 2010-11-22T19:41:07+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Nick <p>@Dick: I think this approach should work fine with Rails &lt; 2&#46;0&#46; The only real difference is that Rails won&#8217;t auto&#45;load the gem for you, so you&#8217;ll have to put some glue into <code>config/environment.rb</code> in the usual spot above the <code>Rails::Initializer</code>&#46; Example:</p> <pre><code>require 'rubygems' gem 'activerecord-jdbcmysql-adapter' </code></pre> <p>@Matthew: typo noted, thanks&#46;</p> Matthew Williams urn:uuid:68611680-1ac6-40ea-a368-a2fb43cfa657 2007-11-07T13:33:51+00:00 2010-11-22T19:41:07+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Matthew Williams <p>Syntax should be: jruby &#45;S gem install activerecord&#45;jdbc&#45;adapter</p> <p>(capital S versus lower&#45;case)</p> <p>Great write up!</p> Dick Davies urn:uuid:55be6ff3-17c4-4a60-b67e-3ec95e9060f7 2007-11-07T01:09:24+00:00 2010-11-22T19:41:08+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Dick Davies <p>Does this onry work with Rails 2&#46;0? </p> <p>The classpath/jar issue is a big PITA when trying to get existing apps to run on JRuby too&#46;</p> labria urn:uuid:6199ffcd-63fb-4c24-a3b6-5604ec28481c 2007-11-06T17:20:00+00:00 2010-11-22T19:41:08+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by labria <p>Wow&#46; That&#8217;s a good one! </p> Nick Sieger urn:uuid:5fa03b7c-e168-4bd4-be31-b0237344c159 2007-11-06T15:00:00+00:00 2010-11-22T18:07:00+00:00 ActiveRecord-JDBC 0.6 Released! <p>Just out is ActiveRecord&#45;JDBC 0&#46;6, the post&#45;RubyConf release&#46;</p> <p>The sparkly new feature is Rails 2&#46;0 support&#46; In the soon&#45;to&#45;be&#45;released Rails 2&#46;0 (edge), Rails will automatically look for and load an adapter gem based on the name of the adapter you specify in <code>database.yml</code>&#46; Example:</p> <pre><code>development: adapter: funkdb ... </code></pre> <p>With this database configuration, Rails will attempt to load the <code>activerecord-funkdb-adapter</code> gem, require the <code>active_record/connection_adapters/funkdb_adapter</code> library, and call the method <code>ActiveRecord::Base.funkdb_connection</code> in order to obtain a connection to the database&#46; (This is the mechanism used to off&#45;load non&#45;core adapters out of the Rails codebase&#46;)</p> <p>We can leverage this convention to make it easier than ever to get started using JRuby with your Rails application&#46; So, the first thing new in the 0&#46;6 release is the name&#46; You now install <code>activerecord-jdbc-adapter</code>:</p> <pre><code>jruby -S gem install activerecord-jdbc-adapter </code></pre> <p>But wait, there&#8217;s more! We also have adapters for four open&#45;source databases, including MySQL, PostgreSQL, and two embedded Java databases, Derby and HSQLDB&#46; And, for your convenience, we&#8217;ve bundled the JDBC drivers in dependent gems, so you don&#8217;t have to go hunting them down if you don&#8217;t have them handy&#46;</p> <p>Check this out&#46; Get a <a href="http://dist.codehaus.org/jruby/jruby-bin-1.0.2.zip">fresh copy of JRuby 1&#46;0&#46;2</a>, unpack it, and add the <code>bin</code> directory to your path&#46; Install the adapter:</p> <pre><code>$ jruby -S gem install activerecord-jdbcderby-adapter --include-dependencies Successfully installed activerecord-jdbcderby-adapter-0.6 Successfully installed activerecord-jdbc-adapter-0.6 Successfully installed jdbc-derby-10.2.2.0 </code></pre> <p>In your Rails application, freeze to edge Rails (soon to be Rails 2&#46;0)&#46;</p> <pre><code>rake rails:freeze:edge </code></pre> <p>Re&#45;run the Rails command, regenerating configuration files&#46;</p> <pre><code>jruby ./vendor/rails/railties/bin/rails . </code></pre> <p>Currently, Rails 2&#46;0 uses <code>openssl</code> for the HMAC digest used in the new cookie session store, so we have to install the <code>jruby-openssl</code> gem:</p> <pre><code>jruby -S gem install jruby-openssl </code></pre> <p>Now, update your config/database&#46;yml as follows:</p> <pre><code>development: adapter: jdbcderby database: db/development </code></pre> <p>Re&#45;run your migrations, and you should now see a Derby database footprint in the <code>db/development</code> directory&#46;</p> <pre><code>$ ls -l db/development total 24 -rw-r--r-- 1 nicksieg nicksieg 38 Nov 6 08:24 db.lck -rw-r--r-- 1 nicksieg nicksieg 4 Nov 6 08:24 dbex.lck drwxr-xr-x 5 nicksieg nicksieg 170 Nov 6 08:24 log/ drwxr-xr-x 65 nicksieg nicksieg 2210 Nov 6 08:24 seg0/ -rw-r--r-- 1 nicksieg nicksieg 882 Nov 6 08:24 service.properties drwxr-xr-x 2 nicksieg nicksieg 68 Nov 6 08:24 tmp/ </code></pre> <p>That&#8217;s it! To <strong>re&#45;emphasize, to make your application run under JRuby, no longer will you need to</strong> a) find and download appropriate JDBC drivers, b) wonder where they should be placed so that JRuby will find them, or c) make custom changes to <code>config/environment.rb</code>&#46; All that&#8217;s taken care of you if you use one of the following adapters:</p> <ul> <li><code>activerecord-jdbcmysql-adapter</code> (MySQL)</li> <li><code>activerecord-jdbcpostgresql-adapter</code> (PostgreSQL)</li> <li><code>activerecord-jdbcderby-adapter</code> (Derby)</li> <li><code>activerecord-jdbchsqldb-adapter</code> (HSQLDB)</li> </ul> <p>If you need to connect to a different database, you&#8217;ll still need to place your database&#8217;s JDBC driver jar file in the appropriate place and use the straight <code>activerecord-jdbc-adapter</code>&#46; Also note that in this case, and for Rails 1&#46;2&#46;x in general, you&#8217;ll still need to add that pesky <code>require</code> statement to <code>config/environment.rb</code>&#46;</p> <p>As always, there are bug fixes too (though we haven&#8217;t been tracking exactly which ones are fixed)&#46; We&#8217;re starting to file <a href="http://jira.codehaus.org/secure/IssueNavigator.jspa?reset=true&amp;&amp;pid=11295&amp;resolution=-1&amp;component=12786&amp;sorter/field=priority&amp;sorter/order=ASC">ActiveRecord&#45;JDBC bugs</a> in the JRuby JIRA now, and will be putting in future AR&#45;JDBC versions to target soon too&#46; So, please <a href="http://jira.codehaus.org/secure/CreateIssue.jspa?pid=11295">file new bugs in JIRA</a> (and select component &#8220;ActiveRecord&#45;JDBC&#8221;) rather than in the antiquated Rubyforge tracker&#46;</p>