Class: ActiveRecord::ConnectionAdapters::JdbcDriver
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::JdbcDriver
- Defined in:
- lib/active_record/connection_adapters/jdbc_adapter.rb
Instance Method Summary collapse
- #connection(url, user, pass) ⇒ Object
- #create ⇒ Object
- #driver_class ⇒ Object
-
#initialize(name) ⇒ JdbcDriver
constructor
A new instance of JdbcDriver.
- #load ⇒ Object
Constructor Details
#initialize(name) ⇒ JdbcDriver
Returns a new instance of JdbcDriver.
245 246 247 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 245 def initialize(name) @name = name end |
Instance Method Details
#connection(url, user, pass) ⇒ Object
270 271 272 273 274 275 276 277 278 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 270 def connection(url, user, pass) Jdbc::DriverManager.getConnection(url, user, pass) rescue # bypass DriverManager to get around problem with dynamically loaded jdbc drivers props = java.util.Properties.new props.setProperty("user", user) props.setProperty("password", pass) create.connect(url, props) end |
#create ⇒ Object
280 281 282 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 280 def create driver_class.new end |
#driver_class ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 249 def driver_class @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 driver_class = Jdbc.const_get(driver_class_const) raise "You specify a driver for your JDBC connection" unless driver_class driver_class end end |
#load ⇒ Object
266 267 268 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 266 def load Jdbc::DriverManager.registerDriver(create) end |