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