class Sequel::JDBC::Dataset
Constants
- PreparedStatementMethods
- StoredProcedureMethods
Public Instance Methods
fetch_rows(sql, &block)
click to toggle source
# File lib/sequel/adapters/jdbc.rb 752 def fetch_rows(sql, &block) 753 execute(sql){|result| process_result_set(result, &block)} 754 self 755 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 763 def with_convert_types(v) 764 clone(:convert_types=>v) 765 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 758 def with_fetch_size(size) 759 clone(:fetch_size=>size) 760 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 791 def basic_type_convertor(map, meta, type, i) 792 map[type] 793 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 770 def convert_types? 771 ct = @opts[:convert_types] 772 ct.nil? ? db.convert_types : ct 773 end
prepare_extend_sproc(ds)
click to toggle source
Extend the dataset with the JDBC
stored procedure methods.
# File lib/sequel/adapters/jdbc.rb 776 def prepare_extend_sproc(ds) 777 ds.with_extend(StoredProcedureMethods) 778 end
prepared_statement_modules()
click to toggle source
# File lib/sequel/adapters/jdbc.rb 795 def prepared_statement_modules 796 [PreparedStatementMethods] 797 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 801 def process_result_set(result) 802 meta = result.getMetaData 803 if fetch_size = opts[:fetch_size] 804 result.setFetchSize(fetch_size) 805 end 806 cols = [] 807 i = 0 808 convert = convert_types? 809 map = convert ? db.type_convertor_map : db.basic_type_convertor_map 810 811 meta.getColumnCount.times do 812 i += 1 813 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)] 814 end 815 max = i 816 self.columns = cols.map{|c| c[0]} 817 818 while result.next 819 row = {} 820 i = -1 821 while (i += 1) < max 822 n, j, pr = cols[i] 823 row[n] = pr.call(result, j) 824 end 825 yield row 826 end 827 ensure 828 result.close 829 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 782 def type_convertor(map, meta, type, i) 783 map[type] 784 end