class Sequel::JDBC::Dataset
Constants
- PreparedStatementMethods
- StoredProcedureMethods
Public Instance Methods
fetch_rows(sql, &block)
click to toggle source
# File lib/sequel/adapters/jdbc.rb 742 def fetch_rows(sql, &block) 743 execute(sql){|result| process_result_set(result, &block)} 744 self 745 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 753 def with_convert_types(v) 754 clone(:convert_types=>v) 755 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 748 def with_fetch_size(size) 749 clone(:fetch_size=>size) 750 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 781 def basic_type_convertor(map, meta, type, i) 782 map[type] 783 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 760 def convert_types? 761 ct = @opts[:convert_types] 762 ct.nil? ? db.convert_types : ct 763 end
prepare_extend_sproc(ds)
click to toggle source
Extend the dataset with the JDBC
stored procedure methods.
# File lib/sequel/adapters/jdbc.rb 766 def prepare_extend_sproc(ds) 767 ds.with_extend(StoredProcedureMethods) 768 end
prepared_statement_modules()
click to toggle source
# File lib/sequel/adapters/jdbc.rb 785 def prepared_statement_modules 786 [PreparedStatementMethods] 787 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 791 def process_result_set(result) 792 meta = result.getMetaData 793 if fetch_size = opts[:fetch_size] 794 result.setFetchSize(fetch_size) 795 end 796 cols = [] 797 i = 0 798 convert = convert_types? 799 map = convert ? db.type_convertor_map : db.basic_type_convertor_map 800 801 meta.getColumnCount.times do 802 i += 1 803 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)] 804 end 805 max = i 806 self.columns = cols.map{|c| c[0]} 807 808 while result.next 809 row = {} 810 i = -1 811 while (i += 1) < max 812 n, j, pr = cols[i] 813 row[n] = pr.call(result, j) 814 end 815 yield row 816 end 817 ensure 818 result.close 819 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 772 def type_convertor(map, meta, type, i) 773 map[type] 774 end