class Sequel::JDBC::Dataset
Constants
- PreparedStatementMethods
- StoredProcedureMethods
Public Instance Methods
fetch_rows(sql, &block)
click to toggle source
# File lib/sequel/adapters/jdbc.rb 725 def fetch_rows(sql, &block) 726 execute(sql){|result| process_result_set(result, &block)} 727 self 728 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 736 def with_convert_types(v) 737 clone(:convert_types=>v) 738 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 731 def with_fetch_size(size) 732 clone(:fetch_size=>size) 733 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 764 def basic_type_convertor(map, meta, type, i) 765 map[type] 766 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 743 def convert_types? 744 ct = @opts[:convert_types] 745 ct.nil? ? db.convert_types : ct 746 end
prepare_extend_sproc(ds)
click to toggle source
Extend the dataset with the JDBC
stored procedure methods.
# File lib/sequel/adapters/jdbc.rb 749 def prepare_extend_sproc(ds) 750 ds.with_extend(StoredProcedureMethods) 751 end
prepared_statement_modules()
click to toggle source
# File lib/sequel/adapters/jdbc.rb 768 def prepared_statement_modules 769 [PreparedStatementMethods] 770 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 774 def process_result_set(result) 775 meta = result.getMetaData 776 if fetch_size = opts[:fetch_size] 777 result.setFetchSize(fetch_size) 778 end 779 cols = [] 780 i = 0 781 convert = convert_types? 782 map = convert ? db.type_convertor_map : db.basic_type_convertor_map 783 784 meta.getColumnCount.times do 785 i += 1 786 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)] 787 end 788 self.columns = cols.map{|c| c[0]} 789 790 while result.next 791 row = {} 792 cols.each do |n, j, pr| 793 row[n] = pr.call(result, j) 794 end 795 yield row 796 end 797 ensure 798 result.close 799 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 755 def type_convertor(map, meta, type, i) 756 map[type] 757 end