class Sequel::JDBC::Dataset
Constants
- PreparedStatementMethods
- StoredProcedureMethods
Public Instance Methods
Source
# File lib/sequel/adapters/jdbc.rb 771 def fetch_rows(sql, &block) 772 execute(sql){|result| process_result_set(result, &block)} 773 self 774 end
Source
# File lib/sequel/adapters/jdbc.rb 782 def with_convert_types(v) 783 clone(:convert_types=>v) 784 end
Set whether to convert Java types to ruby types in the returned dataset.
Source
# File lib/sequel/adapters/jdbc.rb 777 def with_fetch_size(size) 778 clone(:fetch_size=>size) 779 end
Set the fetch size on JDBC ResultSets created from the returned dataset.
Private Instance Methods
Source
# File lib/sequel/adapters/jdbc.rb 810 def basic_type_convertor(map, meta, type, i) 811 map[type] 812 end
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.
Source
# File lib/sequel/adapters/jdbc.rb 789 def convert_types? 790 ct = @opts[:convert_types] 791 ct.nil? ? db.convert_types : ct 792 end
Whether we should convert Java types to ruby types for this dataset.
Source
# File lib/sequel/adapters/jdbc.rb 795 def prepare_extend_sproc(ds) 796 ds.with_extend(StoredProcedureMethods) 797 end
Extend the dataset with the JDBC stored procedure methods.
Source
# File lib/sequel/adapters/jdbc.rb 814 def prepared_statement_modules 815 [PreparedStatementMethods] 816 end
Source
# File lib/sequel/adapters/jdbc.rb 820 def process_result_set(result) 821 meta = result.getMetaData 822 if fetch_size = opts[:fetch_size] 823 result.setFetchSize(fetch_size) 824 end 825 cols = [] 826 i = 0 827 convert = convert_types? 828 map = convert ? db.type_convertor_map : db.basic_type_convertor_map 829 830 meta.getColumnCount.times do 831 i += 1 832 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)] 833 end 834 max = i 835 self.columns = cols.map{|c| c[0]} 836 837 while result.next 838 row = {} 839 i = -1 840 while (i += 1) < max 841 n, j, pr = cols[i] 842 row[n] = pr.call(result, j) 843 end 844 yield row 845 end 846 ensure 847 result.close 848 end
Split out from fetch rows to allow processing of JDBC result sets that don’t come from issuing an SQL string.
Source
# File lib/sequel/adapters/jdbc.rb 801 def type_convertor(map, meta, type, i) 802 map[type] 803 end
The type conversion proc to use for the given column number i, given the type conversion map and the ResultSetMetaData.