File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 5
5
require 'active_record/log_subscriber' # Need to make sure this is loaded before we load Core for monkey patching
6
6
7
7
# Load the jar file for the jdbc driver
8
- require 'jdbc/mssql '
8
+ require_relative './jdbc_mssql_driver_loader '
9
9
10
10
# Standadard arjdbc functionality
11
11
require 'arjdbc/abstract/connection_management'
Original file line number Diff line number Diff line change
1
+ module JdbcMssqlDriverLoader
2
+ def self . check_and_maybe_load_driver
3
+ driver_name = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
4
+ if ( Java ::JavaClass . for_name ( driver_name ) rescue nil )
5
+ driver = Java ::ComMicrosoftSqlserverJdbc ::SQLServerDriver . new
6
+ which = driver
7
+ . getClass ( ) . getClassLoader ( ) . loadClass ( driver_name )
8
+ . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . to_s
9
+ warn "You already required a mssql jdbc driver (#{ which } ), skipping gem jdbc-mssql"
10
+
11
+ major_version = driver . major_version
12
+ required_major_version = 8
13
+ if major_version < required_major_version
14
+ raise "MSSQL jdbc driver version is to old (given major version #{ major_version } < required major version #{ required_major_version } )"
15
+ end
16
+ else
17
+ require "jdbc/mssql"
18
+ end
19
+ end
20
+
21
+ check_and_maybe_load_driver
22
+ end
You can’t perform that action at this time.
0 commit comments