class Sequel::JDBC::Dataset
Constants
- PreparedStatementMethods
- StoredProcedureMethods
Public Instance Methods
fetch_rows(sql, &block)
click to toggle source
# File lib/sequel/adapters/jdbc.rb 770 def fetch_rows(sql, &block) 771 execute(sql){|result| process_result_set(result, &block)} 772 self 773 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 781 def with_convert_types(v) 782 clone(:convert_types=>v) 783 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 776 def with_fetch_size(size) 777 clone(:fetch_size=>size) 778 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 809 def basic_type_convertor(map, meta, type, i) 810 map[type] 811 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 788 def convert_types? 789 ct = @opts[:convert_types] 790 ct.nil? ? db.convert_types : ct 791 end
prepare_extend_sproc(ds)
click to toggle source
Extend the dataset with the JDBC
stored procedure methods.
# File lib/sequel/adapters/jdbc.rb 794 def prepare_extend_sproc(ds) 795 ds.with_extend(StoredProcedureMethods) 796 end
prepared_statement_modules()
click to toggle source
# File lib/sequel/adapters/jdbc.rb 813 def prepared_statement_modules 814 [PreparedStatementMethods] 815 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 819 def process_result_set(result) 820 meta = result.getMetaData 821 if fetch_size = opts[:fetch_size] 822 result.setFetchSize(fetch_size) 823 end 824 cols = [] 825 i = 0 826 convert = convert_types? 827 map = convert ? db.type_convertor_map : db.basic_type_convertor_map 828 829 meta.getColumnCount.times do 830 i += 1 831 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)] 832 end 833 max = i 834 self.columns = cols.map{|c| c[0]} 835 836 while result.next 837 row = {} 838 i = -1 839 while (i += 1) < max 840 n, j, pr = cols[i] 841 row[n] = pr.call(result, j) 842 end 843 yield row 844 end 845 ensure 846 result.close 847 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 800 def type_convertor(map, meta, type, i) 801 map[type] 802 end