Class: JDBCHelper::Connection::PreparedStatement
- Inherits:
-
ParameterizedStatement
- Object
- ParameterizedStatement
- JDBCHelper::Connection::PreparedStatement
- Defined in:
- lib/jdbc-helper/connection/prepared_statement.rb
Overview
enum = pstmt.enumerate(10, 20)
Instance Attribute Summary
Attributes inherited from ParameterizedStatement
Instance Method Summary collapse
-
#add_batch(*params) ⇒ NilClass
Adds to the batch.
-
#clear_batch ⇒ NilClass
Clears the batch.
- #enumerate(*params, &blk) ⇒ JDBCHelper::Connection::ResultSetEnumerator
-
#execute_batch ⇒ Object
Executes the batch.
-
#parameter_count ⇒ Fixnum
Returns the number of parameters required.
-
#query(*params, &blk) ⇒ Array
Returns an Array if block is not given.
-
#set_fetch_size(fsz) ⇒ NilClass
Gives the JDBC driver a hint of the number of rows to fetch from the database by a single interaction.
- #update(*params) ⇒ Fixnum
Methods inherited from ParameterizedStatement
Instance Method Details
#add_batch(*params) ⇒ NilClass
Adds to the batch
52 53 54 55 56 57 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 52 def add_batch(*params) check_closed set_params(params) @java_obj.add_batch end |
#clear_batch ⇒ NilClass
Clears the batch
68 69 70 71 72 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 68 def clear_batch check_closed @java_obj.clear_batch end |
#enumerate(*params, &blk) ⇒ JDBCHelper::Connection::ResultSetEnumerator
41 42 43 44 45 46 47 48 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 41 def enumerate(*params, &blk) check_closed return query(*params, &blk) if block_given? set_params(params) ResultSetEnumerator.new(measure_exec(:p_query) { @java_obj.execute_query }) end |
#execute_batch ⇒ Object
Executes the batch
59 60 61 62 63 64 65 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 59 def execute_batch check_closed measure_exec(:p_execute_batch) { @java_obj.executeBatch } end |
#parameter_count ⇒ Fixnum
Returns the number of parameters required
17 18 19 20 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 17 def parameter_count @pmd ||= @java_obj. @pmd.get_parameter_count end |
#query(*params, &blk) ⇒ Array
Returns an Array if block is not given
31 32 33 34 35 36 37 38 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 31 def query(*params, &blk) check_closed set_params(params) # sorry, ignoring privacy @conn.send(:process_and_close_rset, measure_exec(:p_query) { @java_obj.execute_query }, &blk) end |
#set_fetch_size(fsz) ⇒ NilClass
Gives the JDBC driver a hint of the number of rows to fetch from the database by a single interaction. This is only a hint. It may no effect at all.
77 78 79 80 81 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 77 def set_fetch_size(fsz) check_closed @java_obj.set_fetch_size fsz end |
#update(*params) ⇒ Fixnum
23 24 25 26 27 28 |
# File 'lib/jdbc-helper/connection/prepared_statement.rb', line 23 def update(*params) check_closed set_params(params) measure_exec(:p_update) { @java_obj.execute_update } end |