Nick Sieger: ActiveRecord-JDBC 0.6 Released! do what you love tag:blog.nicksieger.com,2005:Typo Typo 2007-11-19T15:37:43+00:00 Nick urn:uuid:10e3f83c-92f3-49e9-a5f3-94cffec304b5 2007-11-19T15:37:42+00:00 2007-11-19T15:37:43+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. You use the activerecord-jdbc-adapter gem only, with the standard configuration. See the <a href='http://jruby-extras.rubyforge.org/activrecord-jdbc-adapter' rel="nofollow">documentation</a> for details.</p> Tom urn:uuid:d1ca86d5-3cea-4928-ae6d-10b3eb3a8d3d 2007-11-19T11:50:45+00:00 2007-11-19T11:50:46+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Tom <p>How do you configure it for Oracle? There is no activerecord-oracle-adapter gem.</p> Nick urn:uuid:fc17e368-77ad-49e7-96cd-0d2ab555c06a 2007-11-07T20:26:35+00:00 2007-11-07T20:26:35+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Nick <p>@François: yes, unfortunately we have the embedded derby URL hard-coded in the jdbc_derby.rb file in the activerecord-jdbc-adapter codebase, so you&#8217;ll have to use the url/driver properties in your database.yml. But you still should be able to use adapter == &#8216;jdbcderby&#8217;.</p> Francois Orsini urn:uuid:ca96ddc0-34c8-4d56-a7b8-738b3e73bd3e 2007-11-07T19:48:56+00:00 2007-11-07T19:48:56+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Francois Orsini <p>This is great stuffs Nick. 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-jdbc-adapter and set the appropriate settings (driver class &amp; connection URL) as well as placing the derbyclient.jar in that case in some appropriate location&#8230; The activerecord-jdbcderby-adapter is only to connect to a embedded Derby instance, right? Cheers.</p> Oliver Schmelzle urn:uuid:ad4c9c63-31c7-438b-9104-04d0b2ec74e6 2007-11-07T19:44:34+00:00 2007-11-07T19:44:34+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Oliver Schmelzle <p>Thanks for releasing this new version.</p> <p>When using Radiant 0.6.3 with ActiveRecord-JDBC 0.6 I noticed migrations were failing due to a problem with renaming column names.</p> <p>I filed a bug and fix for this issue at:</p> <p><a href='http://jira.codehaus.org/browse/JRUBY-1543' rel="nofollow">http://jira.codehaus.org/browse/JRUBY-1543</a></p> Nick urn:uuid:c4744472-2fee-431d-bd60-059bbc161413 2007-11-07T18:09:06+00:00 2007-11-07T18:09:06+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Nick <p>@Dick: I think this approach should work fine with Rails &lt; 2.0. The only real difference is that Rails won&#8217;t auto-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>. Example:</p> <pre><code>require 'rubygems' gem 'activerecord-jdbcmysql-adapter' </code></pre> <p>@Matthew: typo noted, thanks.</p> Matthew Williams urn:uuid:68611680-1ac6-40ea-a368-a2fb43cfa657 2007-11-07T13:33:51+00:00 2007-11-07T13:33:51+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Matthew Williams <p>Syntax should be: jruby -S gem install activerecord-jdbc-adapter</p> <p>(capital S versus lower-case)</p> <p>Great write up!</p> Dick Davies urn:uuid:55be6ff3-17c4-4a60-b67e-3ec95e9060f7 2007-11-07T01:09:24+00:00 2007-11-07T01:09:24+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by Dick Davies <p>Does this onry work with Rails 2.0? </p> <p>The classpath/jar issue is a big PITA when trying to get existing apps to run on JRuby too.</p> labria urn:uuid:6199ffcd-63fb-4c24-a3b6-5604ec28481c 2007-11-06T17:20:00+00:00 2007-11-06T17:20:00+00:00 Comment on ActiveRecord-JDBC 0.6 Released! by labria <p>Wow. That&#8217;s a good one! </p> Nick Sieger urn:uuid:5fa03b7c-e168-4bd4-be31-b0237344c159 2007-11-06T15:00:00+00:00 2007-11-07T18:06:39+00:00 ActiveRecord-JDBC 0.6 Released! <p>Just out is ActiveRecord-JDBC 0.6, the post-RubyConf release.</p> <p>The sparkly new feature is Rails 2.0 support. In the soon-to-be-released Rails 2.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>. 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. (This is the mechanism used to off-load non-core adapters out of the Rails codebase.)</p> <p>We can leverage this convention to make it easier than ever to get started using JRuby with your Rails application. So, the first thing new in the 0.6 release is the name. 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-source databases, including MySQL, PostgreSQL, and two embedded Java databases, Derby and HSQLDB. 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.</p> <p>Check this out. Get a <a href="http://dist.codehaus.org/jruby/jruby-bin-1.0.2.zip">fresh copy of JRuby 1.0.2</a>, unpack it, and add the <code>bin</code> directory to your path. 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.0).</p> <pre><code>rake rails:freeze:edge </code></pre> <p>Re-run the Rails command, regenerating configuration files.</p> <pre><code>jruby ./vendor/rails/railties/bin/rails . </code></pre> <p>Currently, Rails 2.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.yml as follows:</p> <pre><code>development: adapter: jdbcderby database: db/development </code></pre> <p>Re-run your migrations, and you should now see a Derby database footprint in the <code>db/development</code> directory.</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-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>. 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>. Also note that in this case, and for Rails 1.2.x in general, you&#8217;ll still need to add that pesky <code>require</code> statement to <code>config/environment.rb</code>.</p> <p>As always, there are bug fixes too (though we haven&#8217;t been tracking exactly which ones are fixed). 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-JDBC bugs</a> in the JRuby JIRA now, and will be putting in future AR-JDBC versions to target soon too. So, please <a href="http://jira.codehaus.org/secure/CreateIssue.jspa?pid=11295">file new bugs in JIRA</a> (and select component &#8220;ActiveRecord-JDBC&#8221;) rather than in the antiquated Rubyforge tracker.</p>