Module: ArJdbc::Abstract::Core

Overview

This is minimum amount of code needed from base JDBC Adapter class to make common adapters work. This replaces using jdbc/adapter as a base class for all adapters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/arjdbc/abstract/core.rb', line 10

def config
  @config
end

Instance Method Details

#initialize(connection, logger = nil, config = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/arjdbc/abstract/core.rb', line 12

def initialize(connection, logger = nil, config = {})
  @config = config

  if self.class.equal? ActiveRecord::ConnectionAdapters::JdbcAdapter
    spec = @config.key?(:adapter_spec) ? @config[:adapter_spec] :
               ( @config[:adapter_spec] = adapter_spec(@config) ) # due resolving visitor
    extend spec if spec
  end

  connection ||= jdbc_connection_class(config[:adapter_spec]).new(config, self)

  super(connection, logger, config) # AbstractAdapter

  connection.configure_connection # will call us (maybe)
end

#jdbc_connection(unwrap = nil) ⇒ Java::JavaSql::Connection

Retrieve the raw java.sql.Connection object. The unwrap parameter is useful if an attempt to unwrap a pooled (JNDI) connection should be made - to really return the 'native' JDBC object.

Parameters:

  • unwrap (true, false) (defaults to: nil)

    whether to unwrap the connection object

Returns:

  • (Java::JavaSql::Connection)

    the JDBC connection



33
34
35
# File 'lib/arjdbc/abstract/core.rb', line 33

def jdbc_connection(unwrap = nil)
  raw_connection.jdbc_connection(unwrap)
end