Files

Class/Module Index [+]

Quicksearch

ActiveRecord::ConnectionAdapters::JdbcConnection::ConfigHelper

Attributes

config[R]

Public Instance Methods

config=(config) click to toggle source
# File lib/arjdbc/jdbc/connection.rb, line 70
def config=(config)
  @config = config.symbolize_keys
end
configure_connection() click to toggle source

Configure this connection from the available configuration. @see configure_jdbc @see configure_jndi

@note this has nothing to do with the configure_connection implemented on some of the concrete adapters (e.g. {#ArJdbc::Postgres})

# File lib/arjdbc/jdbc/connection.rb, line 80
def configure_connection
  config[:retry_count] ||= 5
  config[:connection_alive_sql] ||= "select 1"
  if config[:jndi]
    begin
      configure_jndi
    rescue => e
      warn "JNDI data source unavailable: #{e.message}; trying straight JDBC"
      configure_jdbc
    end
  else
    configure_jdbc
  end
end
configure_jdbc() click to toggle source
# File lib/arjdbc/jdbc/connection.rb, line 103
def configure_jdbc
  if ! config[:url] || ( ! config[:driver] && ! config[:driver_instance] )
    raise ::ActiveRecord::ConnectionNotEstablished, "jdbc adapter requires :driver class and :url"
  end

  url = configure_url
  username = config[:username].to_s
  password = config[:password].to_s
  jdbc_driver = ( config[:driver_instance] ||= 
      JdbcDriver.new(config[:driver].to_s, config[:properties]) )

  @connection_factory = JdbcConnectionFactory.impl do
    jdbc_driver.connection(url, username, password)
  end
end
configure_jndi() click to toggle source
# File lib/arjdbc/jdbc/connection.rb, line 95
def configure_jndi
  data_source = javax.naming.InitialContext.new.lookup config[:jndi].to_s
  @jndi_connection = true
  @connection_factory = JdbcConnectionFactory.impl do
    data_source.connection
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.