class Sequel::JDBC::Dataset

def convert_type_proc(v)

class, return false so that the negative lookup is cached.
class to a ruby object. If no callable object can handle v's
Return a callable object that will convert any value of v's
def convert_type_proc(v)
  case v
  when JAVA_BIG_DECIMAL
    DECIMAL_METHOD
  when JAVA_SQL_TIMESTAMP
    method(:convert_type_timestamp)
  when JAVA_SQL_TIME
    TIME_METHOD
  when JAVA_SQL_DATE
    DATE_METHOD
  when JAVA_BUFFERED_READER
    BUFFERED_READER_METHOD
  when JAVA_BYTE_ARRAY
    BYTE_ARRAY_METHOD
  when JAVA_SQL_BLOB
    BLOB_METHOD
  when JAVA_SQL_CLOB
    CLOB_METHOD
  else
    false
  end
end

def convert_type_timestamp(v)

Convert the given Java timestamp to an instance of Sequel.datetime_class.
def convert_type_timestamp(v)
  db.to_application_timestamp([v.getYear + 1900, v.getMonth + 1, v.getDate, v.getHours, v.getMinutes, v.getSeconds, v.getNanos])
end

def fetch_rows(sql, &block)

Correctly return rows from the database and return them as hashes.
def fetch_rows(sql, &block)
  execute(sql){|result| process_result_set(result, &block)}
  self
end

def prepare(type, name=nil, *values)

database (and connection) for reuse.
Create a named prepared statement that is stored in the
def prepare(type, name=nil, *values)
  ps = to_prepared_statement(type, values)
  ps.extend(PreparedStatementMethods)
  if name
    ps.prepared_statement_name = name
    db.prepared_statements[name] = ps
  end
  ps
end

def prepare_extend_sproc(ds)

Extend the dataset with the JDBC stored procedure methods.
def prepare_extend_sproc(ds)
  ds.extend(StoredProcedureMethods)
end

def process_result_set(result, &block)

that don't come from issuing an SQL string.
Split out from fetch rows to allow processing of JDBC result sets
def process_result_set(result, &block)
  # get column names
  meta = result.getMetaData
  cols = []
  i = 0
  meta.getColumnCount.times{cols << [output_identifier(meta.getColumnLabel(i+=1)), i]}
  columns = cols.map{|c| c.at(0)}
  if opts[:offset] && offset_returns_row_number_column?
    rn = row_number_column
    columns.delete(rn)
  end
  @columns = columns
  ct = @convert_types
  if (ct.nil? ? db.convert_types : ct)
    cols.each{|c| c << nil}
    process_result_set_convert(cols, result, rn, &block)
  else
    process_result_set_no_convert(cols, result, rn, &block)
  end
ensure
  result.close
end

def process_result_set_convert(cols, result, rn)

and return the result, otherwise, return the object.
later processing. If the conversion proc exists, call it
the result of as the column's conversion proc to speed up
call convert_type_proc to get the conversion method. Cache
* if a conversion proc hasn't been looked up yet (nil value),
exist (false value), return object.
* if a conversion proc has already been looked up and doesn't
and return the result.
* if a conversion proc is not false/nil, call it with the object
the column when parsing the column metadata.
since unlike other adapters, Sequel doesn't get the type of
the column. All columns start with a nil conversion proc,
* otherwise, see if a conversion method exists for
* if not truthy, return object
* check if the value is truthy (not false/nil)
is roughly, for each column value in each row:
from the database. This has been optimized, the algorithm it uses
Use conversion procs to convert data retrieved
def process_result_set_convert(cols, result, rn)
  while result.next
    row = {}
    cols.each do |n, i, p|
      v = result.getObject(i)
      row[n] = if v
        if p
          p.call(v)
        elsif p.nil?
          cols[i-1][2] = p = convert_type_proc(v)
          if p
            p.call(v)
          else
            v
          end
        else
          v
        end
      else
        v
      end
    end
    row.delete(rn) if rn
    yield row
  end
end

def process_result_set_no_convert(cols, result, rn)

may yield Java values and not ruby values.
Yield rows without calling any conversion procs. This
def process_result_set_no_convert(cols, result, rn)
  while result.next
    row = {}
    cols.each{|n, i| row[n] = result.getObject(i)}
    row.delete(rn) if rn
    yield row
  end
end