def self.new(uri_s)
uri = DataObjects::URI::parse(uri_s)
case uri.scheme.to_sym
when :java
warn 'JNDI URLs (connection strings) are only for use with JRuby' unless RUBY_PLATFORM =~ /java/
driver_name = uri.query.delete("scheme")
conn_uri = uri.to_s.gsub(/\?$/, '')
when :jdbc
warn 'JDBC URLs (connection strings) are only for use with JRuby' unless RUBY_PLATFORM =~ /java/
path = uri.path.sub(/jdbc:/, '')
driver_name = if path.split(':').first == 'sqlite'
'sqlite3'
elsif path.split(':').first == 'postgresql'
'postgres'
else
path.split(':').first
end
conn_uri = uri_s
else
driver_name = uri.scheme
conn_uri = uri
end
driver_class = if driver_name == 'sqlserver'
'SqlServer'
else
driver_name.capitalize
end
clazz = DataObjects.const_get(driver_class)::Connection
unless clazz.method_defined? :close
if (uri.scheme.to_sym == :java)
clazz.class_eval do
alias close dispose
end
else
clazz.class_eval do
include Pooling
alias close release
end
end
end
clazz.new(conn_uri)
end