Nick Sieger: Tag jdbc http://blog.nicksieger.com/articles/tag/jdbc?tag=jdbc en-us 40 activerecord-jdbc-adapter 1.0.0 <p>Just a quick note that <code>activerecord-jdbc-adapter</code> has finally hit 1&#46;0&#46;0&#46; Install it today:</p> <pre><code>gem install activerecord-jdbc-adapter </code></pre> <p>Included are adapters for <a href="http://www.mysql.com/" title="MySQL :: The world's most popular open source database">MySQL</a>, <a href="http://www.postgresql.org/" title="PostgreSQL: The world's most advanced open source database">PostgreSQL</a>, <a href="http://www.sqlite.org/" title="SQLite Home Page">SQLite3</a>, <a href="http://db.apache.org/derby/" title="Apache Derby">Derby</a>, <a href="http://hsqldb.org/" title="HSQLDB">HSQLDB</a>, <a href="http://www.h2database.com/" title="H2 Database Engine">H2</a>, and <a href="http://www.microsoft.com/sqlserver/2008/en/us/" title="SQL Server 2008 Overview, data platform, store data | Microsoft">Microsoft SQL Server</a>&#46;</p> <pre><code>gem install activerecord-jdbcmysql-adapter gem install activerecord-jdbcpostgresql-adapter gem install activerecord-jdbcsqlite3-adapter gem install activerecord-jdbcderby-adapter gem install activerecord-jdbchsqldb-adapter gem install activerecord-jdbch2-adapter gem install activerecord-jdbcmssql-adapter </code></pre> <p>You can also use <code>activerecord-jdbc-adapter</code> with Oracle, DB2, Sybase, and Informix&#46; Just ensure that the database JDBC driver jar files are mentioned in <code>$CLASSPATH</code> or <code>require</code> them directly in your script or application&#46; Then, configure <code>database.yml</code> with <code>adapter:</code> set to one of <code>oracle</code>, <code>db2</code>, <code>sybase</code>, or <code>informix</code>&#46;</p> <p>This release promises superb compatibility with Rails 3&#46; We now have the ActiveRecord test suite <a href="http://ci.jruby.org/view/Rails">running in CI</a> and the 1&#46;0&#46;0 release is 100% green when run on MySQL&#46; (SQLite3 is right behind with just 13 failures, and we hope to fix those soon&#46;)</p> <p>As <a href="/articles/2010/02/24/jruby-and-rails-3-sitting-in-a-tree">mentioned before</a>, to get started with Rails 3, JRuby and <code>activerecord-jdbc-adapter</code>, simply run:</p> <pre><code>$ rails new app --database mysql --template http://jruby.org ... apply http://jruby.org apply http://jruby.org/templates/default.rb gsub Gemfile gsub config/database.yml $ cd app &amp;&amp; bundle install ... Using activerecord-jdbc-adapter (1.0.0) ... Using jdbc-mysql (5.0.4) ... Using rails (3.0.0) Your bundle is complete! Use `bundle show [gemname]` ... </code></pre> <p>One new feature in 1&#46;0&#46;0 is the ability to define an extension adapter for your proprietary JDBC database without needing to hack the <code>activerecord-jdbc-adapter</code> source code&#46; To get you started we extracted the <code>activerecord-cachedb-adapter</code> and <a href="http://github.com/nicksieger/activerecord-cachedb-adapter">put it on Github</a> for you to use as a template&#46;</p> <p>The 1&#46;0&#46;0 release had over 200 commits poured into it and lots of great help from the community&#46; Thanks to David Kellum, Dmitry Denisov, Dwayne Litzenberger, Gregor Schmidt, James Walker, John Duff, Joshua Suggs, Nicholas J Kreucher, Peter Donald, Geoff Longman, Uwe Kubosch, Youhei Kondou, Michael Pitman, Alex B, and Ryan Bell for their contributions to this release&#46;</p> <p>Enjoy!</p> Thu, 14 Oct 2010 15:25:51 +0000 urn:uuid:8f70150f-ec57-4646-afaa-c3e07b6df7c3 Nick Sieger http://blog.nicksieger.com/articles/2010/10/14/activerecord-jdbc-adapter-1-0-0 jruby jdbc activerecord rails rails3 http://blog.nicksieger.com/articles/trackback/573 Fresh 0.9.2 activerecord-jdbc-adapter Release <p>As <a href="http://markmail.org/message/mkwdu56wp74pj4tf">announced last week on the jruby&#45;user list</a>, 0&#46;9&#46;2, the latest <code>activerecord-jdbc-adapter</code> release, has been pushed out&#46; Please install the gem in the usual fashion and try it out on your applications&#46;</p> <p>One of the <a href="http://jira.codehaus.org/browse/JRUBY-3502">most contentious bugs</a> broke <code>db:create</code> and <code>db:drop</code>, ruining the quick&#45;start workflow that Rails is known for&#46; To fix this, a creative solution was needed that ended up bringing some nice benefits&#46;</p> <p>The problem stemmed from the fact that some database setup tasks in Rails 2&#46;3 no longer load the environment; instead they just load the configuration data and work with that&#46; This means that there is no easy way to hook into Rails and override those tasks, which is <a href="http://github.com/nicksieger/activerecord-jdbc-adapter/blob/master/lib/jdbc_adapter/jdbc.rake">what activerecord&#45;jdbc needs to do</a>&#46;</p> <p>The solution I ended up with was to create a <code>jdbc</code> Rails generator that inserts a couple files into your rails application that inject the JDBC logic into ActiveRecord and the database rake tasks&#46; To wit:</p> <pre><code>$ jruby script/generate jdbc exists config/initializers create config/initializers/jdbc.rb exists lib/tasks create lib/tasks/jdbc.rake </code></pre> <p>The upside of this new technique is that now that we have a way to ensure the JDBC adapter is properly injected into Rails, and you no longer need to use adapter names like <code>jdbcmysql</code>, <code>jdbcsqlite3</code> and the like&#46; The net result is that <strong>database&#46;yml no longer needs to be modified</strong> for the default Rails databases (<code>mysql</code>, <code>sqlite3</code>, <code>postgresql</code>)&#46; So while we introduced one additional step in the process to bootstrap a Rails application under JRuby, the removal the step where <code>database.yml</code> needs to be modified results in a more predictable workflow&#46;</p> <p>The new JRuby&#45;specific Rails workflow looks like the following, assuming you&#8217;ve installed the <code>activerecord-jdbc-adapter</code> gem into JRuby, along with the appropriate database driver gem (e&#46;g, <code>jdbc-mysql</code>)&#46; (Of course, the gems only need to be installed once per JRuby installation&#46;)</p> <ol> <li>Create your Rails application as usual&#46;</li> <li>Run the <code>jdbc</code> generator as shown above&#46;</li> <li>Profit!</li> </ol> <p>Additionally, if you maintain a <a href="http://m.onkey.org/2008/12/4/rails-templates">Rails application template</a> that you use to start a new application, you can simply add <code>generate(:jdbc)</code> to that template&#8217;s script&#46;</p> <p>What&#8217;s more, the presence of the JDBC files in your application are guarded and only inject JDBC support when running under JRuby, so you can safely keep them around when running Rails under multiple Ruby implementations&#46;</p> <p>For more details of what&#8217;s in the release please consult the <a href="http://rubyforge.org/forum/forum.php?forum_id=34972">mini&#45;changelog on Rubyforge</a> and the <a href="http://kenai.com/jira/browse/ACTIVERECORD_JDBC/fixforversion/10195">list of fixed issues in JIRA</a>&#46;</p> Mon, 12 Oct 2009 18:30:45 +0000 urn:uuid:65e528d4-1673-400f-b67c-60f97a152db4 Nick Sieger http://blog.nicksieger.com/articles/2009/10/12/fresh-0-9-2-activerecord-jdbc-adapter-release jruby activerecord jdbc http://blog.nicksieger.com/articles/trackback/528