class Sequel::JDBC::Dataset

Constants

PreparedStatementMethods
StoredProcedureMethods

Public Instance Methods

fetch_rows(sql, &block) click to toggle source
# File lib/sequel/adapters/jdbc.rb, line 704
def fetch_rows(sql, &block)
  execute(sql){|result| process_result_set(result, &block)}
  self
end
with_convert_types(v) click to toggle source

Set whether to convert Java types to ruby types in the returned dataset.

# File lib/sequel/adapters/jdbc.rb, line 715
def with_convert_types(v)
  clone(:convert_types=>v)
end
with_fetch_size(size) click to toggle source

Set the fetch size on JDBC ResultSets created from the returned dataset.

# File lib/sequel/adapters/jdbc.rb, line 710
def with_fetch_size(size)
  clone(:fetch_size=>size)
end

Private Instance Methods

basic_type_convertor(map, meta, type, i) click to toggle source

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 743
def basic_type_convertor(map, meta, type, i)
  map[type]
end
convert_types?() click to toggle source

Whether we should convert Java types to ruby types for this dataset.

# File lib/sequel/adapters/jdbc.rb, line 722
def convert_types?
  ct = @opts[:convert_types]
  ct.nil? ? db.convert_types : ct
end
prepare_extend_sproc(ds) click to toggle source

Extend the dataset with the JDBC stored procedure methods.

# File lib/sequel/adapters/jdbc.rb, line 728
def prepare_extend_sproc(ds)
  ds.with_extend(StoredProcedureMethods)
end
prepared_statement_modules() click to toggle source
# File lib/sequel/adapters/jdbc.rb, line 747
def prepared_statement_modules
  [PreparedStatementMethods]
end
process_result_set(result) { |row| ... } click to toggle source

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 753
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
  self.columns = cols.map{|c| c[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
type_convertor(map, meta, type, i) click to toggle source

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 734
def type_convertor(map, meta, type, i)
  map[type]
end