Module: Jdbc::Postgres

Defined in:
lib/jdbc/postgres.rb,
lib/jdbc/postgres/version.rb

Constant Summary collapse

DRIVER_VERSION =
'9.4.1206'
VERSION =
DRIVER_VERSION

Class Method Summary collapse

Class Method Details

.driver_jarObject



7
8
9
10
11
12
13
14
# File 'lib/jdbc/postgres.rb', line 7

def self.driver_jar
  version_jdbc_version = DRIVER_VERSION.split( '.' )
  if ( jdbc_v = jdbc_version ).is_a? Float
    jdbc_v = (jdbc_v * 10).to_i
  end
  version_jdbc_version << jdbc_v
  'postgresql-%s.%s-%s-jdbc%d.jar' % version_jdbc_version
end

.driver_nameObject



26
27
28
# File 'lib/jdbc/postgres.rb', line 26

def self.driver_name
  'org.postgresql.Driver'
end

.jdbc_versionObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jdbc/postgres.rb', line 30

def self.jdbc_version
  version = ENV_JAVA[ 'java.specification.version' ]
  version = version.split('.').last.to_i # '1.7' => 7
  if version < 6
    3 # not supported
  elsif version == 6
    4
  else # JDBC >= 4.1
    4.1
  end
end

.load_driver(method = :load) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/jdbc/postgres.rb', line 16

def self.load_driver(method = :load)
  send method, driver_jar
rescue LoadError => e
  if jdbc_version < 4
    warn "failed to load postgresql (driver) jar, please note that we no longer " <<
    "include JDBC 3.x support, on Java < 6 please use gem 'jdbc-postgres', '~> 9.2'"
  end
  raise e
end