Module: Spider::Model::Storage::Db::Connectors::JDBC

Defined in:
lib/spiderfw/model/storage/db/connectors/jdbc.rb

Constant Summary

Mutex =
java.lang.Object.new
DriverManager =
java.sql.DriverManager
Statement =
java.sql.Statement
Types =
java.sql.Types

Class Method Summary collapse

Class Method Details

.driver_class(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/spiderfw/model/storage/db/connectors/jdbc.rb', line 10

def self.driver_class(name)
    driver_class ||= begin
        driver_class_const = (name[0...1].capitalize + name[1..name.length]).gsub(/\./, '_')
        JDBC::Mutex.synchronized do
            unless JDBC.const_defined?(driver_class_const)
                driver_class_name = name
                JDBC.module_eval do
                    include_class(driver_class_name) { driver_class_const }
                end
            end
        end
        JDBC.const_get(driver_class_const)
    end
    JDBC::DriverManager.registerDriver(driver_class)
    @driver_classes ||= {}
    @driver_classes[name] = driver_class
    driver_class
end