class Sequel::JDBC::Dataset
Attributes
Whether to convert some Java types to ruby types when retrieving rows. Uses the database's setting by default, can be set to false to roughly double performance when fetching rows.
Public Instance Methods
Correctly return rows from the database and return them as hashes.
# File lib/sequel/adapters/jdbc.rb, line 724 def fetch_rows(sql, &block) execute(sql){|result| process_result_set(result, &block)} self end
Create a named prepared statement that is stored in the database (and connection) for reuse.
# File lib/sequel/adapters/jdbc.rb, line 731 def prepare(type, name=nil, *values) ps = to_prepared_statement(type, values) ps.extend(PreparedStatementMethods) if name ps.prepared_statement_name = name db.set_prepared_statement(name, ps) end ps end
Set the fetch size on JDBC ResultSets created from this dataset.
# File lib/sequel/adapters/jdbc.rb, line 742 def with_fetch_size(size) clone(:fetch_size=>size) end
Private Instance Methods
The basic type conversion proc to use for the given column number i, given the type conversion map and the ResultSetMetaData.
This is implemented as a separate method so that subclasses can override the methods separately.
# File lib/sequel/adapters/jdbc.rb, line 770 def basic_type_convertor(map, meta, type, i) map[type] end
Whether we should convert Java types to ruby types for this dataset.
# File lib/sequel/adapters/jdbc.rb, line 749 def convert_types? ct = @convert_types ct.nil? ? db.convert_types : ct end
Extend the dataset with the JDBC stored procedure methods.
# File lib/sequel/adapters/jdbc.rb, line 755 def prepare_extend_sproc(ds) ds.extend(StoredProcedureMethods) end
Split out from fetch rows to allow processing of JDBC result sets that don't come from issuing an SQL string.
# File lib/sequel/adapters/jdbc.rb, line 776 def process_result_set(result) meta = result.getMetaData if fetch_size = opts[:fetch_size] result.setFetchSize(fetch_size) end cols = [] i = 0 convert = convert_types? map = convert ? db.type_convertor_map : db.basic_type_convertor_map meta.getColumnCount.times do i += 1 cols << [output_identifier(meta.getColumnLabel(i)), i, convert ? type_convertor(map, meta, meta.getColumnType(i), i) : basic_type_convertor(map, meta, meta.getColumnType(i), i)] end @columns = cols.map{|c| c.at(0)} while result.next row = {} cols.each do |n, j, pr| row[n] = pr.call(result, j) end yield row end ensure result.close end
The type conversion proc to use for the given column number i, given the type conversion map and the ResultSetMetaData.
# File lib/sequel/adapters/jdbc.rb, line 761 def type_convertor(map, meta, type, i) map[type] end