Title: [708] trunk/activerecord-jdbc: - Fix Jon's code so we don't have to require 'jruby'
- Revision
- 708
- Author
- nicksieger
- Date
- 2007-08-24 03:07:34 -0400 (Fri, 24 Aug 2007)
Log Message
- Fix Jon's code so we don't have to require 'jruby'
- Update history for 0.5 release
Modified Paths
Diff
Modified: trunk/activerecord-jdbc/History.txt (707 => 708)
--- trunk/activerecord-jdbc/History.txt 2007-08-24 06:11:16 UTC (rev 707)
+++ trunk/activerecord-jdbc/History.txt 2007-08-24 07:07:34 UTC (rev 708)
@@ -1,9 +1,14 @@
== 0.5
+- Release coincides with JRuby 1.0.1 release
- It is no longer necessary to specify :driver and :url configuration parameters for the mysql,
postgresql, oracle, derby, hsqldb, and h2 adapters. The previous configuration is still
valid and compatible, but for new applications, this makes it possible to use the exact same
- database.yml configuration as Rails applications running under Matz Ruby.
+ database.yml configuration as Rails applications running under native Ruby.
+- JDBC drivers can now be dynamically loaded by Ruby code, without being on the classpath prior to
+ launching JRuby. Simply use "require 'jdbc-driver.jar'" in JRuby code to add it to the runtime
+ classpath.
+- Updates to HSQL, MS SQLServer, Postgres, Oracle and Derby adapters
== 0.4
Modified: trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb (707 => 708)
--- trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb 2007-08-24 06:11:16 UTC (rev 707)
+++ trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb 2007-08-24 07:07:34 UTC (rev 708)
@@ -197,8 +197,16 @@
end
def driver_class
- require 'jruby'
- JRuby.runtime.getJRubyClassLoader.loadClass(@name)
+ @driver_class ||= begin
+ driver_class_const = (@name[0...1].capitalize + @[EMAIL PROTECTED]).gsub(/\./, '_')
+ unless Jdbc.const_defined?(driver_class_const)
+ driver_class_name = @name
+ Jdbc.module_eval do
+ include_class(driver_class_name) { driver_class_const }
+ end
+ end
+ Jdbc.const_get(driver_class_const)
+ end
end
def load
@@ -206,7 +214,7 @@
end
def create
- driver_class.newInstance
+ driver_class.new
end
end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel