JNDI_URI_REGEXP | = | /\Ajdbc:jndi:(.+)/ | Used to identify a jndi connection and to extract the jndi resource name. | |
DECIMAL_TYPE_RE | = | /number|numeric|decimal/io | The types to check for 0 scale to transform :decimal types to :integer. | |
DATABASE_SETUP | = | {} | Contains procs keyed on subadapter type that extend the given database object so it supports the correct database type. | |
StoredProcedureMethods | = | prepared_statements_module( "sql = @sproc_name; opts = Hash[opts]; opts[:args] = @sproc_args; opts[:sproc] = true", Sequel::Dataset::StoredProcedureMethods, %w"execute execute_dui") do private |
Attempt to load the JDBC driver class, which should be specified as a string containing the driver class name (which JRuby should autoload). Note that the string is evaled, so this method is not safe to call with untrusted input. Raise a Sequel::AdapterNotFound if evaluating the class name raises a NameError.
# File lib/sequel/adapters/jdbc.rb, line 55 55: def self.load_driver(drv, gem=nil) 56: load_gem(gem) if gem 57: eval drv 58: rescue NameError 59: raise Sequel::AdapterNotFound, "#{drv} not loaded#{", try installing jdbc-#{gem.to_s.downcase} gem" if gem}" 60: end
Allow loading the necessary JDBC support via a gem.
# File lib/sequel/adapters/jdbc.rb, line 37 37: def self.load_gem(name) 38: begin 39: require "jdbc/#{name.to_s.downcase}" 40: rescue LoadError 41: # jdbc gem not used, hopefully the user has the .jar in their CLASSPATH 42: else 43: if defined?(::Jdbc) && ( ::Jdbc.const_defined?(name) rescue nil ) 44: jdbc_module = ::Jdbc.const_get(name) # e.g. Jdbc::SQLite3 45: jdbc_module.load_driver if jdbc_module.respond_to?(:load_driver) 46: end 47: end 48: end