This repository was archived by the owner on Apr 17, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,36 @@ module Adapters
1010 # @api private
1111 def self . new ( repository_name , options )
1212 options = normalize_options ( options )
13- adapter_class ( options . fetch ( :adapter ) ) . new ( repository_name , options )
13+
14+ case options . fetch ( :adapter )
15+ when 'java'
16+ # discover the real adapter
17+ jndi_uri = "#{ options [ :scheme ] } :#{ options [ :path ] } "
18+ context = javax . naming . InitialContext . new
19+ ds = context . lookup ( jndi_uri )
20+ conn = ds . getConnection
21+ begin
22+ metadata = conn . getMetaData
23+ driver_name = metadata . getDriverName
24+
25+ driver = case driver_name
26+ when /mysql/i then 'mysql'
27+ when /oracle/i then 'oracle'
28+ when /postgres/i then 'postgres'
29+ when /sqlite/i then 'sqlite'
30+ when /sqlserver|tds|Microsoft SQL/i then 'sqlserver'
31+ else
32+ nil # not supported
33+ end # case
34+ options [ :adapter ] = driver
35+ ensure
36+ conn . close
37+ end
38+ else
39+ driver = options . fetch ( :adapter )
40+ end # case
41+
42+ adapter_class ( driver ) . new ( repository_name , options )
1443 end
1544
1645 # The path used to require the in memory adapter
You can’t perform that action at this time.
0 commit comments