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