Diff
Modified: trunk/activerecord-jdbc/History.txt (741 => 742)
--- trunk/activerecord-jdbc/History.txt 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/History.txt 2007-09-21 19:29:39 UTC (rev 742)
@@ -1,3 +1,10 @@
+== 0.6
+
+- Gem is renamed to "activerecord-jdbc-adapter" to follow new conventions introduced in Rails 2.0 for third-party adapters. Rails 2.0 compatibility is introduced.
+- Add dependency on ActiveRecord >= 1.14 (from the Rails 1.1.x release)
+- New drivers (jdbc-XXX) and adapter (activerecord-jdbcXXX-adapter) gems available separately. See the README.txt file for details.
+- Plain "jdbc" driver is still available if you want to use the full driver/url way of specifying the driver.
+
== 0.5
- Release coincides with JRuby 1.0.1 release
Modified: trunk/activerecord-jdbc/README.txt (741 => 742)
--- trunk/activerecord-jdbc/README.txt 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/README.txt 2007-09-21 19:29:39 UTC (rev 742)
@@ -26,50 +26,42 @@
* rename_column
* HSQLDB - Complete
-Other databases will require testing and likely a custom configuration module. Please join the
-jruby-extras mailing-list[http://rubyforge.org/mail/?group_id=2014] to help us discover support for more databases.
+Other databases will require testing and likely a custom configuration module. Please join the jruby-extras mailing-list[http://rubyforge.org/mail/?group_id=2014] to help us discover support for more databases.
== Using ActiveRecord JDBC
-=== Standalone, with ActiveRecord
+=== Inside Rails
-1. Install the gem with JRuby:
- jruby --command gem install ActiveRecord-JDBC
-2. Ensure the following code gets executed in your script:
- require 'rubygems'
- gem 'ActiveRecord-JDBC'
- require 'jdbc_adapter'
- require 'active_record'
+To use ActiveRecord-JDBC with JRuby on Rails:
-3. After this you can establish a JDBC connection like this:
- ActiveRecord::Base.establish_connection(
- :adapter => 'jdbc',
- :driver => 'org.apache.derby.jdbc.EmbeddedDriver',
- :url ="" 'jdbc:derby:test_ar;create=true'
- )
+1. Choose the adapter you wish to gem install. The following pre-packaged adapters are available:
-Provided you have the derby libraries in your classpath, this is enough
-to establish an in-memory JDBC connection. The required parameters to
-establish_connection for ActiveRecord JDBC are:
+ * base jdbc (<tt>activerecord-jdbc-adapter</tt>). Supports all available databases via JDBC, but requires you to download and manually install the database vendor's JDBC driver .jar file.
+ * mysql (<tt>activerecord-jdbcmysql-adapter</tt>)
+ * postgres (<tt>activerecord-jdbcpostgres-adapter</tt>)
+ * derby (<tt>activerecord-jdbcderby-adapter</tt>)
+ * hsqldb (<tt>activerecord-jdbchsqldb-adapter</tt>)
-* adapter
-* driver
-* url
+2. If you're using Rails 2.0, you may skip to the next step. For Rails prior to version 2.0,you'll need to add one-time setup to your config/environment.rb file in your Rails application. Add the following lines just before the <code>Rails::Initializer</code>.
-If provided, password and username will be used. After the connection is established
-Active Record can be used as usual.
+ if RUBY_PLATFORM =~ /java/
+ require 'rubygems'
+ gem 'activerecord-jdbc-adapter'
+ require 'jdbc_adapter'
+ end
-=== Inside Rails
+3. Configure your database.yml to use the <code>jdbc</code> adapter.
+For mysql, postgres, derby, oracle, hsqldb and h2 you can simply configure the database in the normal Rails style.
-To use ActiveRecord-JDBC with JRuby on Rails:
+ development:
+ adapter: mysql
+ username: blog
+ password:
+ hostname: localhost
+ database: weblog_development
-1. Install the gem with JRuby:
- jruby --command gem install ActiveRecord-JDBC
-2. Add one-time setup to your config/environment.rb file in your Rails application. Add the following lines just before the <code>Rails::Initializer</code>.
- require 'rubygems'
- gem 'ActiveRecord-JDBC'
- require 'jdbc_adapter'
-3. Configure your database.yml to use the <code>jdbc</code> adapter. For now, you'll need to know the database driver class and URL. Example:
+For other databases, you'll need to know the database driver class and URL. Example:
+
development:
adapter: jdbc
username: blog
@@ -77,14 +69,42 @@
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/weblog_development
+=== Standalone, with ActiveRecord
+
+1. Install the gem with JRuby:
+
+ jruby -S gem install activerecord-jdbc-adapter
+
+ If you wish to use the adapter for a specific database, you can install it directly and a driver gem will be installed as well:
+
+ jruby -S gem install activerecord-jdbcderby-adapter
+
+2. If using ActiveRecord 2.0 (Rails 2.0) or greater, you can skip to the next step. Otherwise, ensure the following code gets executed in your script:
+
+ require 'rubygems'
+ gem 'activerecord-jdbc-adapter'
+ require 'jdbc_adapter'
+ require 'active_record'
+
+3. After this you can establish a JDBC connection like this:
+
+ ActiveRecord::Base.establish_connection(
+ :adapter => 'jdbcderby',
+ :database => "db/my-database"
+ )
+
+ or like this (but requires that you manually put the driver jar on the classpath):
+
+ ActiveRecord::Base.establish_connection(
+ :adapter => 'jdbc',
+ :driver => 'org.apache.derby.jdbc.EmbeddedDriver',
+ :url ="" 'jdbc:derby:test_ar;create=true'
+ )
+
== Running AR-JDBC's Tests
-By default hsql, mysql, and derby are run. In order to run all tests you
-must download each of the databases about put their JDBC drivers in your
-classpath. Here is an example of I use:
+Drivers for 4 open-source databases are included. Provided you have MySQL installed, you can simply type <tt>jruby -S rake</tt> to run the tests. A database named <tt>weblog_development</tt> is needed beforehand with a connection user of "blog" and password empty.
- CLASSPATH=~/opt/derby/lib/derby.jar:~/opt/mysql/mysql-connector-java-3.1.14-bin.jar:~/opt/hsqldb/lib/hsqldb.jar jruby ../jruby/bin/jruby --command rake
-
== Authors
This project was written by Nick Sieger <[EMAIL PROTECTED]> and Ola Bini <[EMAIL PROTECTED]> with lots of help from the JRuby community.
@@ -92,3 +112,5 @@
== License
ActiveRecord-JDBC is released under a BSD license. See the LICENSE file included with the distribution for details.
+
+Driver gems for ActiveRecord JDBC are licensed under the same license the database's drivers are licensed. See each driver gem's LICENSE file for details.
\ No newline at end of file
Modified: trunk/activerecord-jdbc/Rakefile (741 => 742)
--- trunk/activerecord-jdbc/Rakefile 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/Rakefile 2007-09-21 19:29:39 UTC (rev 742)
@@ -82,17 +82,18 @@
end
Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
+require File.dirname(__FILE__) + "/lib/jdbc_adapter/version"
begin
require 'hoe'
- require File.dirname(__FILE__) + "/lib/jdbc_adapter/version"
- Hoe.new("ActiveRecord-JDBC", JdbcAdapter::Version::VERSION) do |p|
+ Hoe.new("activerecord-jdbc-adapter", JdbcAdapter::Version::VERSION) do |p|
p.rubyforge_name = "jruby-extras"
- p.url = ""
+ p.url = ""
p.author = "Nick Sieger, Ola Bini and JRuby contributors"
p.email = "[EMAIL PROTECTED], [EMAIL PROTECTED]"
p.summary = "JDBC adapter for ActiveRecord, for use within JRuby on Rails."
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
p.description = p.paragraphs_of('README.txt', 0...1).join("\n\n")
+ p.extra_deps << ['activerecord', ">= 1.14"]
end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
rescue LoadError
puts "You really need Hoe installed to be able to package this gem"
Added: trunk/activerecord-jdbc/adapters/derby/Rakefile (0 => 742)
--- trunk/activerecord-jdbc/adapters/derby/Rakefile (rev 0)
+++ trunk/activerecord-jdbc/adapters/derby/Rakefile 2007-09-21 19:29:39 UTC (rev 742)
@@ -0,0 +1,29 @@
+MANIFEST = FileList["Manifest.txt", "Rakefile", "LICENSE.txt", "lib/**/*"]
+
+file "Manifest.txt" => :manifest
+task :manifest do
+ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
+end
+Rake::Task['manifest'].invoke
+
+require File.dirname(__FILE__) + "/../../lib/jdbc_adapter/version"
+require File.dirname(__FILE__) + "/../../drivers/derby/lib/derby"
+begin
+ require 'hoe'
+ Hoe.new("activerecord-jdbcderby-adapter", JdbcAdapter::Version::VERSION) do |p|
+ p.rubyforge_name = "jruby-extras"
+ p.url = ""
+ p.author = "Nick Sieger, Ola Bini and JRuby contributors"
+ p.email = "[EMAIL PROTECTED], [EMAIL PROTECTED]"
+ p.summary = "Derby JDBC adapter for JRuby on Rails."
+ p.changes = "Updated to Derby version #{DERBY_VERSION}."
+ p.description = "Install this gem to use Derby with JRuby on Rails."
+ p.extra_deps += [
+ ['activerecord-jdbc-adapter', ">= #{JdbcAdapter::Version::VERSION}"],
+ ['jdbc-derby', ">= #{DERBY_VERSION}"]]
+ end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
+rescue LoadError
+ puts "You really need Hoe installed to be able to package this gem"
+rescue => e
+ puts "ignoring error while loading hoe: #{e.to_s}"
+end
Added: trunk/activerecord-jdbc/adapters/derby/lib/active_record/connection_adapters/jdbcderby_adapter.rb (0 => 742)
--- trunk/activerecord-jdbc/adapters/derby/lib/active_record/connection_adapters/jdbcderby_adapter.rb (rev 0)
+++ trunk/activerecord-jdbc/adapters/derby/lib/active_record/connection_adapters/jdbcderby_adapter.rb 2007-09-21 19:29:39 UTC (rev 742)
@@ -0,0 +1,20 @@
+tried_gem = false
+begin
+ require "jdbc_adapter"
+rescue LoadError
+ raise if tried_gem
+ require 'rubygems'
+ gem "activerecord-jdbc-adapter"
+ tried_gem = true
+ retry
+end
+tried_gem = false
+begin
+ require ""
+rescue LoadError
+ raise if tried_gem
+ require 'rubygems'
+ gem "activerecord-jdbc-adapter"
+ tried_gem = true
+ retry
+end
Added: trunk/activerecord-jdbc/drivers/derby/Rakefile (0 => 742)
--- trunk/activerecord-jdbc/drivers/derby/Rakefile (rev 0)
+++ trunk/activerecord-jdbc/drivers/derby/Rakefile 2007-09-21 19:29:39 UTC (rev 742)
@@ -0,0 +1,27 @@
+MANIFEST = FileList["Manifest.txt", "Rakefile", "LICENSE.txt", "lib/**/*"]
+
+file "Manifest.txt" => :manifest
+task :manifest do
+ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
+end
+Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
+
+require File.dirname(__FILE__) + "/../../lib/jdbc_adapter/version"
+$LOAD_PATH << "lib"
+require "derby"
+begin
+ require 'hoe'
+ Hoe.new("jdbc-derby", DERBY_VERSION) do |p|
+ p.rubyforge_name = "jruby-extras"
+ p.url = ""
+ p.author = "Nick Sieger, Ola Bini and JRuby contributors"
+ p.email = "[EMAIL PROTECTED], [EMAIL PROTECTED]"
+ p.summary = "Derby/JavaDB JDBC driver for Java and Derby/ActiveRecord-JDBC."
+ p.changes = "Updated to Derby version #{DERBY_VERSION}."
+ p.description = "Install this gem and require 'derby' within JRuby to load the driver."
+ end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
+rescue LoadError
+ puts "You really need Hoe installed to be able to package this gem"
+rescue => e
+ puts "ignoring error while loading hoe: #{e.to_s}"
+end
Modified: trunk/activerecord-jdbc/drivers/derby/lib/derby.rb (741 => 742)
--- trunk/activerecord-jdbc/drivers/derby/lib/derby.rb 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/drivers/derby/lib/derby.rb 2007-09-21 19:29:39 UTC (rev 742)
@@ -1 +1,2 @@
-require 'derby-10.2.2.0.jar'
\ No newline at end of file
+DERBY_VERSION = "10.2.2.0"
+require "derby-#{DERBY_VERSION}.jar"
\ No newline at end of file
Added: trunk/activerecord-jdbc/drivers/hsqldb/Rakefile (0 => 742)
--- trunk/activerecord-jdbc/drivers/hsqldb/Rakefile (rev 0)
+++ trunk/activerecord-jdbc/drivers/hsqldb/Rakefile 2007-09-21 19:29:39 UTC (rev 742)
@@ -0,0 +1,26 @@
+MANIFEST = FileList["Manifest.txt", "Rakefile", "LICENSE.txt", "lib/**/*"]
+
+file "Manifest.txt" => :manifest
+task :manifest do
+ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
+end
+Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
+
+$LOAD_PATH << "lib"
+require "hsqldb"
+begin
+ require 'hoe'
+ Hoe.new("jdbc-hsqldb", HSQLDB_VERSION) do |p|
+ p.rubyforge_name = "jruby-extras"
+ p.url = ""
+ p.author = "Nick Sieger, Ola Bini and JRuby contributors"
+ p.email = "[EMAIL PROTECTED], [EMAIL PROTECTED]"
+ p.summary = "HSQLDB JDBC driver for Java and HSQLDB/ActiveRecord-JDBC."
+ p.changes = "Updated to HSQLDB version #{HSQLDB_VERSION}."
+ p.description = "Install this gem and require 'hsqldb' within JRuby to load the driver."
+ end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
+rescue LoadError
+ puts "You really need Hoe installed to be able to package this gem"
+rescue => e
+ puts "ignoring error while loading hoe: #{e.to_s}"
+end
Modified: trunk/activerecord-jdbc/drivers/hsqldb/lib/hsqldb.rb (741 => 742)
--- trunk/activerecord-jdbc/drivers/hsqldb/lib/hsqldb.rb 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/drivers/hsqldb/lib/hsqldb.rb 2007-09-21 19:29:39 UTC (rev 742)
@@ -1 +1,2 @@
-require 'hsqldb-1.8.0.7.jar'
\ No newline at end of file
+HSQLDB_VERSION = "1.8.0.7"
+require "hsqldb-#{HSQLDB_VERSION}.jar"
\ No newline at end of file
Modified: trunk/activerecord-jdbc/drivers/mysql/Rakefile (741 => 742)
--- trunk/activerecord-jdbc/drivers/mysql/Rakefile 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/drivers/mysql/Rakefile 2007-09-21 19:29:39 UTC (rev 742)
@@ -6,7 +6,6 @@
end
Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
-require File.dirname(__FILE__) + "/../../lib/jdbc_adapter/version"
$LOAD_PATH << "lib"
require "mysql"
begin
Property changes: trunk/activerecord-jdbc/drivers/postgres
Name: svn:ignore
+ pkg
Manifest.txt
Added: trunk/activerecord-jdbc/drivers/postgres/LICENSE.txt (0 => 742)
--- trunk/activerecord-jdbc/drivers/postgres/LICENSE.txt (rev 0)
+++ trunk/activerecord-jdbc/drivers/postgres/LICENSE.txt 2007-09-21 19:29:39 UTC (rev 742)
@@ -0,0 +1,12 @@
+PostgreSQL Database Management System
+(formerly known as Postgres, then as Postgres95)
+
+Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
\ No newline at end of file
Added: trunk/activerecord-jdbc/drivers/postgres/Rakefile (0 => 742)
--- trunk/activerecord-jdbc/drivers/postgres/Rakefile (rev 0)
+++ trunk/activerecord-jdbc/drivers/postgres/Rakefile 2007-09-21 19:29:39 UTC (rev 742)
@@ -0,0 +1,26 @@
+MANIFEST = FileList["Manifest.txt", "Rakefile", "LICENSE.txt", "lib/**/*"]
+
+file "Manifest.txt" => :manifest
+task :manifest do
+ File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
+end
+Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
+
+$LOAD_PATH << "lib"
+require "postgres"
+begin
+ require 'hoe'
+ Hoe.new("jdbc-postgres", POSTGRES_VERSION) do |p|
+ p.rubyforge_name = "jruby-extras"
+ p.url = ""
+ p.author = "Nick Sieger, Ola Bini and JRuby contributors"
+ p.email = "[EMAIL PROTECTED], [EMAIL PROTECTED]"
+ p.summary = "PostgreSQL JDBC driver for Java and PostgreSQL/ActiveRecord-JDBC."
+ p.changes = "Updated to PostgreSQL version #{POSTGRES_VERSION}."
+ p.description = "Install this gem and require 'postgres' within JRuby to load the driver."
+ end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
+rescue LoadError
+ puts "You really need Hoe installed to be able to package this gem"
+rescue => e
+ puts "ignoring error while loading hoe: #{e.to_s}"
+end
Modified: trunk/activerecord-jdbc/drivers/postgres/lib/postgres.rb (741 => 742)
--- trunk/activerecord-jdbc/drivers/postgres/lib/postgres.rb 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/drivers/postgres/lib/postgres.rb 2007-09-21 19:29:39 UTC (rev 742)
@@ -1 +1,2 @@
-require 'postgresql-8.2-504.jdbc3.jar'
\ No newline at end of file
+POSTGRES_VERSION = "8.2"
+require "postgresql-#{POSTGRES_VERSION}-504.jdbc3.jar"
\ No newline at end of file
Modified: trunk/activerecord-jdbc/lib/jdbc_adapter.rb (741 => 742)
--- trunk/activerecord-jdbc/lib/jdbc_adapter.rb 2007-09-15 22:18:04 UTC (rev 741)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter.rb 2007-09-21 19:29:39 UTC (rev 742)
@@ -1,12 +1,24 @@
if RUBY_PLATFORM =~ /java/
- if defined?(RAILS_CONNECTION_ADAPTERS)
- RAILS_CONNECTION_ADAPTERS << %q(jdbc)
- else
- RAILS_CONNECTION_ADAPTERS = %w(jdbc)
+ begin
+ tried_gem ||= false
+ require 'active_record/version'
+ rescue LoadError
+ raise if tried_gem
+ require 'rubygems'
+ gem 'activerecord'
+ tried_gem = true
+ retry
end
- if defined?(RAILS_GEM_VERSION) && RAILS_GEM_VERSION =~ /1\.1\.\d+/
- require 'active_record/connection_adapters/jdbc_adapter'
+ if ActiveRecord::VERSION::MAJOR < 2
+ if defined?(RAILS_CONNECTION_ADAPTERS)
+ RAILS_CONNECTION_ADAPTERS << %q(jdbc)
+ else
+ RAILS_CONNECTION_ADAPTERS = %w(jdbc)
+ end
+ if ActiveRecord::VERSION::MAJOR == 1 && ActiveRecord::VERSION::MINOR == 14
+ require 'active_record/connection_adapters/jdbc_adapter'
+ end
end
else
- $stderr.print "warning: ActiveRecord-JDBC is for use with JRuby only\n"
+ warn "ActiveRecord-JDBC is for use with JRuby only"
end