Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion lib/dm-core/adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,36 @@ module Adapters
# @api private
def self.new(repository_name, options)
options = normalize_options(options)
adapter_class(options.fetch(:adapter)).new(repository_name, options)

case options.fetch(:adapter)
when 'java'
# discover the real adapter
jndi_uri = "#{options[:scheme]}:#{options[:path]}"
context = javax.naming.InitialContext.new
ds= context.lookup(jndi_uri)
conn = ds.getConnection
begin
metadata = conn.getMetaData
driver_name = metadata.getDriverName

driver = case driver_name
when /mysql/i then 'mysql'
when /oracle/i then 'oracle'
when /postgres/i then 'postgres'
when /sqlite/i then 'sqlite'
when /sqlserver|tds|Microsoft SQL/i then 'sqlserver'
else
nil # not supported
end # case
options[:adapter] = driver
ensure
conn.close
end
else
driver = options.fetch(:adapter)
end # case

adapter_class(driver).new(repository_name, options)
end

# The path used to require the in memory adapter
Expand Down