Permalink
Browse files

backports from master for jTDS 1.2.7

  • Loading branch information...
kares committed Jan 23, 2013
1 parent ad0e798 commit eb0ef117e24bd2539c8f3061af00f04767be12e3
Showing with 13 additions and 18 deletions.
  1. +13 −18 jdbc-jtds/lib/jdbc/jtds.rb
View
@@ -1,32 +1,27 @@
+warn "Jdbc-JTDS is only for use with JRuby" if (JRUBY_VERSION.nil? rescue true)
+
module Jdbc
module JTDS
- VERSION = "1.2.7"
+ DRIVER_VERSION = '1.2.7'
+ VERSION = DRIVER_VERSION
def self.driver_jar
- "jtds-#{VERSION}.jar"
+ "jtds-#{DRIVER_VERSION}.jar"
end
def self.load_driver(method = :load)
- vers = Java::java.lang.System::get_property( "java.specification.version" )
- vers = vers.split( '.' ).map { |v| v.to_i }
- if ( ( vers <=> [ 1, 7 ] ) >= 0 )
- send method, driver_jar
- else
- raise LoadError.new("Driver not loaded! Version #{VERSION} of jdbc-jtds requires Java 1.7 or later.")
- end
+ send method, driver_jar
end
def self.driver_name
'net.sourceforge.jtds.jdbc.Driver'
end
- end
-end
-if $VERBOSE && (JRUBY_VERSION.nil? rescue true)
- warn "Jdbc-JTDS is only for use with JRuby"
-end
-
-unless Java::JavaLang::Boolean.get_boolean("arjdbc.skip.autoload")
- warn "Autoloading driver which is now deprecated. Set arjdbc.skip.autoload=true to disable autoload."
- Jdbc::JTDS::load_driver :require
+ if defined?(JRUBY_VERSION) && # enable backwards-compat behavior :
+ ( Java::JavaLang::Boolean.get_boolean("jdbc.driver.autoload") ||
+ Java::JavaLang::Boolean.get_boolean("jdbc.jtds.autoload") )
+ warn "autoloading JDBC driver on require 'jdbc/jtds'" if $VERBOSE
+ load_driver :require
+ end
+ end
end

0 comments on commit eb0ef11

Please sign in to comment.