Parent

Included Modules

Class Index [+]

Quicksearch

ActiveRecord::ConnectionAdapters::JdbcAdapter

Attributes

config[R]

Public Class Methods

new(connection, logger, config) click to toggle source
    # File lib/arjdbc/jdbc/adapter.rb, line 26
26:       def initialize(connection, logger, config)
27:         @config = config
28:         spec = adapter_spec config
29:         unless connection
30:           connection_class = jdbc_connection_class spec
31:           connection = connection_class.new config
32:         end
33:         super(connection, logger)
34:         extend spec if spec
35:         configure_arel2_visitors(config)
36:         connection.adapter = self
37:         JndiConnectionPoolCallbacks.prepare(self, connection)
38:       end

Public Instance Methods

_execute(sql, name = nil) click to toggle source

we need to do it this way, to allow Rails stupid tests to always work even if we define a new execute method. Instead of mixing in a new execute, an _execute should be mixed in.

     # File lib/arjdbc/jdbc/adapter.rb, line 190
190:       def _execute(sql, name = nil)
191:         @connection.execute(sql)
192:       end
active?() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 166
166:       def active?
167:         @connection.active?
168:       end
adapter_spec(config) click to toggle source

Locate specialized adapter specification if one exists based on config data

    # File lib/arjdbc/jdbc/adapter.rb, line 56
56:       def adapter_spec(config)
57:         2.times do
58:           dialect = (config[:dialect] || config[:driver]).to_s
59:           ::ArJdbc.constants.map { |name| ::ArJdbc.const_get name }.each do |constant|
60:             if constant.respond_to? :adapter_matcher
61:               spec = constant.adapter_matcher(dialect, config)
62:               return spec if spec
63:             end
64:           end
65: 
66:           # If nothing matches and we're using jndi, try to automatically detect the database.
67:           break unless config[:jndi] and !config[:dialect]
68:           begin
69:             conn = Java::javax.naming.InitialContext.new.lookup(config[:jndi]).getConnection
70:             config[:dialect] = conn.getMetaData.getClass.getName.downcase
71: 
72:             # Derby-specific hack
73:             if ::ArJdbc::Derby.adapter_matcher(config[:dialect], config)
74:               # Needed to set the correct database schema name
75:               config[:username] ||= conn.getMetaData.getUserName
76:             end
77:           rescue
78:             conn.close
79:           end
80:         end
81:         nil
82:       end
arel2_visitors() click to toggle source
    # File lib/arjdbc/jdbc/adapter.rb, line 92
92:       def arel2_visitors
93:         {}
94:       end
begin_db_transaction() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 245
245:       def begin_db_transaction
246:         @connection.begin
247:       end
commit_db_transaction() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 249
249:       def commit_db_transaction
250:         @connection.commit
251:       end
configure_arel2_visitors(config) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 96
 96:       def configure_arel2_visitors(config)
 97:         if defined?(::Arel::Visitors::VISITORS)
 98:           visitors = ::Arel::Visitors::VISITORS
 99:           visitor = nil
100:           arel2_visitors.each do |k,v|
101:             visitor = v
102:             visitors[k] = v unless visitors.has_key?(k)
103:           end
104:           if visitor && config[:dialect] && config[:adapter] =~ /^(jdbc|jndi)$/
105:             visitors[config[:adapter]] = visitor
106:           end
107:         end
108:       end
disconnect!() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 175
175:       def disconnect!
176:         @connection.disconnect!
177:       end
execute(sql, name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 179
179:       def execute(sql, name = nil)
180:         if name == :skip_logging
181:           _execute(sql)
182:         else
183:           log(sql, name) { _execute(sql) }
184:         end
185:       end
indexes(table_name, name = nil, schema_name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 241
241:       def indexes(table_name, name = nil, schema_name = nil)
242:         @connection.indexes(table_name, name, schema_name)
243:       end
insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 223
223:       def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
224:         id = execute(sql, name = nil)
225:         id_value || id
226:       end
jdbc_column_class() click to toggle source
    # File lib/arjdbc/jdbc/adapter.rb, line 46
46:       def jdbc_column_class
47:         ActiveRecord::ConnectionAdapters::JdbcColumn
48:       end
jdbc_columns(table_name, name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 228
228:       def jdbc_columns(table_name, name = nil)
229:         @connection.columns(table_name.to_s)
230:       end
jdbc_connection() click to toggle source

Retrieve the raw java.sql.Connection object.

    # File lib/arjdbc/jdbc/adapter.rb, line 51
51:       def jdbc_connection
52:         raw_connection.connection
53:       end
jdbc_connection_class(spec) click to toggle source
    # File lib/arjdbc/jdbc/adapter.rb, line 40
40:       def jdbc_connection_class(spec)
41:         connection_class = spec.jdbc_connection_class if spec && spec.respond_to?(:jdbc_connection_class)
42:         connection_class = ::ActiveRecord::ConnectionAdapters::JdbcConnection unless connection_class
43:         connection_class
44:       end
jdbc_insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 194
194:       def jdbc_insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
195:         insert_sql(sql, name, pk, id_value, sequence_name)
196:       end
jdbc_select_all(sql, name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 201
201:       def jdbc_select_all(sql, name = nil)
202:         select(sql, name)
203:       end
modify_types(tp) click to toggle source
    # File lib/arjdbc/jdbc/adapter.rb, line 84
84:       def modify_types(tp)
85:         tp
86:       end
native_sql_to_type(tp) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 131
131:       def native_sql_to_type(tp)
132:         if /^(.*?)\(([0-9]+)\)/ =~ tp
133:           tname = $1
134:           limit = $2.to_i
135:           ntype = native_database_types
136:           if ntype[:primary_key] == tp
137:             return :primary_key,nil
138:           else
139:             ntype.each do |name,val|
140:               if name == :primary_key
141:                 next
142:               end
143:               if val[:name].downcase == tname.downcase && (val[:limit].nil? || val[:limit].to_i == limit)
144:                 return name,limit
145:               end
146:             end
147:           end
148:         elsif /^(.*?)/ =~ tp
149:           tname = $1
150:           ntype = native_database_types
151:           if ntype[:primary_key] == tp
152:             return :primary_key,nil
153:           else
154:             ntype.each do |name,val|
155:               if val[:name].downcase == tname.downcase && val[:limit].nil?
156:                 return name,nil
157:               end
158:             end
159:           end
160:         else
161:           return :string,255
162:         end
163:         return nil,nil
164:       end
pk_and_sequence_for(table) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 261
261:       def pk_and_sequence_for(table)
262:         key = primary_key(table)
263:         [key, nil] if key
264:       end
primary_key(table) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 266
266:       def primary_key(table)
267:         primary_keys(table).first
268:       end
primary_keys(table) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 270
270:       def primary_keys(table)
271:         @connection.primary_keys(table)
272:       end
reconnect!() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 170
170:       def reconnect!
171:         @connection.reconnect!
172:         @connection
173:       end
rollback_db_transaction() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 253
253:       def rollback_db_transaction
254:         @connection.rollback
255:       end
select(*args) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 274
274:       def select(*args)
275:         execute(*args)
276:       end
select_one(sql, name = nil) click to toggle source

Do we need this? Not in AR 3.

     # File lib/arjdbc/jdbc/adapter.rb, line 212
212:         def select_one(sql, name = nil)
213:           select(sql, name).first
214:         end
select_rows(sql, name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 217
217:       def select_rows(sql, name = nil)
218:         rows = []
219:         select(sql, name).each {|row| rows << row.values }
220:         rows
221:       end
supports_migrations?() click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 119
119:       def supports_migrations?
120:         true
121:       end
table_exists?(name) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 237
237:       def table_exists?(name)
238:         jdbc_columns(name) rescue nil
239:       end
tables(name = nil) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 233
233:       def tables(name = nil)
234:         @connection.tables
235:       end
write_large_object(*args) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 257
257:       def write_large_object(*args)
258:         @connection.write_large_object(*args)
259:       end

Protected Instance Methods

translate_exception(e, message) click to toggle source
     # File lib/arjdbc/jdbc/adapter.rb, line 278
278:       def translate_exception(e, message)
279:         puts e.backtrace if $DEBUG || ENV['DEBUG']
280:         super
281:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.