module Sequel::JDBC

  1. lib/sequel/adapters/jdbc.rb
  2. lib/sequel/adapters/jdbc/db2.rb
  3. lib/sequel/adapters/jdbc/derby.rb
  4. lib/sequel/adapters/jdbc/h2.rb
  5. lib/sequel/adapters/jdbc/hsqldb.rb
  6. lib/sequel/adapters/jdbc/jtds.rb
  7. lib/sequel/adapters/jdbc/mssql.rb
  8. lib/sequel/adapters/jdbc/mysql.rb
  9. lib/sequel/adapters/jdbc/oracle.rb
  10. lib/sequel/adapters/jdbc/postgresql.rb
  11. lib/sequel/adapters/jdbc/sqlanywhere.rb
  12. lib/sequel/adapters/jdbc/sqlite.rb
  13. lib/sequel/adapters/jdbc/sqlserver.rb
  14. lib/sequel/adapters/jdbc/transactions.rb
  15. show all

Methods

Public Class

  1. load_driver
  2. load_gem

Constants

DATABASE_ERROR_CLASSES = [NativeException]  

Default database error classes

DATABASE_SETUP = {}  

Contains procs keyed on subadapter type that extend the given database object so it supports the correct database type.

JNDI_URI_REGEXP = /\Ajdbc:jndi:(.+)/  

Used to identify a jndi connection and to extract the jndi resource name.

NativeException = java.lang.Exception  

Create custom NativeException alias for nicer access, and also so that JRuby 9.2+ so it doesn't use the deprecated ::NativeException

Public Class methods

load_driver(drv, gem=nil)

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.

[show source]
   # File lib/sequel/adapters/jdbc.rb
52 def self.load_driver(drv, gem=nil)
53   load_gem(gem) if gem
54   if drv.is_a?(String)
55     eval drv
56   else
57     *try, last = drv
58     try.each do |try_drv|
59       begin
60         return eval(try_drv)
61       rescue NameError
62       end
63     end
64 
65     eval last
66   end
67 rescue NameError
68   raise Sequel::AdapterNotFound, "#{drv} not loaded#{", try installing jdbc-#{gem.to_s.downcase} gem" if gem}"
69 end
load_gem(name)

Allow loading the necessary JDBC support via a gem.

[show source]
   # File lib/sequel/adapters/jdbc.rb
34 def self.load_gem(name)
35   begin
36     require "jdbc/#{name.to_s.downcase}"
37   rescue LoadError
38     # jdbc gem not used, hopefully the user has the .jar in their CLASSPATH
39   else
40     if defined?(::Jdbc) && ( ::Jdbc.const_defined?(name) rescue nil )
41       jdbc_module = ::Jdbc.const_get(name) # e.g. Jdbc::SQLite3
42       jdbc_module.load_driver if jdbc_module.respond_to?(:load_driver)
43     end
44   end
45 end