Class: Baza::JdbcDriver
- Inherits:
-
BaseSqlDriver
- Object
- BaseSqlDriver
- Baza::JdbcDriver
- Defined in:
- lib/baza/jdbc_driver.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#conns ⇒ Object
readonly
Returns the value of attribute conns.
Attributes inherited from BaseSqlDriver
#baza, #cols, #indexes, #sep_col, #sep_table, #sep_val, #tables
Instance Method Summary collapse
-
#close ⇒ Object
Closes the connection threadsafe.
-
#initialize(baza) ⇒ JdbcDriver
constructor
A new instance of JdbcDriver.
-
#query(str) ⇒ Object
Executes a query and returns the result.
-
#query_ubuf(str) ⇒ Object
Executes an unbuffered query and returns the result that can be used to access the data.
-
#result_set_killer(id) ⇒ Object
This method handels the closing of statements and results for the Java MySQL-mode.
Methods inherited from BaseSqlDriver
#esc_col, #escape, from_object, #insert_multi, #transaction
Constructor Details
#initialize(baza) ⇒ JdbcDriver
Returns a new instance of JdbcDriver.
16 17 18 19 20 |
# File 'lib/baza/jdbc_driver.rb', line 16 def initialize(baza) @java_rs_data = {} @mutex = ::Mutex.new super end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
14 15 16 |
# File 'lib/baza/jdbc_driver.rb', line 14 def conn @conn end |
#conns ⇒ Object (readonly)
Returns the value of attribute conns.
14 15 16 |
# File 'lib/baza/jdbc_driver.rb', line 14 def conns @conns end |
Instance Method Details
#close ⇒ Object
Closes the connection threadsafe.
55 56 57 |
# File 'lib/baza/jdbc_driver.rb', line 55 def close @mutex.synchronize { @conn.close } end |
#query(str) ⇒ Object
Executes a query and returns the result.
33 34 35 36 37 |
# File 'lib/baza/jdbc_driver.rb', line 33 def query(str) query_with_statement(str, @preload_results) do @conn.create_statement end end |
#query_ubuf(str) ⇒ Object
Executes an unbuffered query and returns the result that can be used to access the data.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/baza/jdbc_driver.rb', line 40 def query_ubuf(str) query_with_statement(str, false) do stmt = @conn.create_statement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY) if @baza.opts[:type] == :sqlite3_java stmt.fetch_size = 1 else stmt.fetch_size = java.lang.Integer::MIN_VALUE end stmt end end |
#result_set_killer(id) ⇒ Object
This method handels the closing of statements and results for the Java MySQL-mode.
23 24 25 26 27 28 29 30 |
# File 'lib/baza/jdbc_driver.rb', line 23 def result_set_killer(id) data = @java_rs_data[id] return nil unless data data[:res].close data[:stmt].close @java_rs_data.delete(id) end |