Class: Baza::JdbcDriver
- Inherits:
-
BaseSqlDriver
- Object
- BaseSqlDriver
- Baza::JdbcDriver
- Defined in:
- lib/baza/jdbc_driver.rb
Direct Known Subclasses
Constant Summary
Constants inherited from BaseSqlDriver
BaseSqlDriver::SELECT_ARGS_ALLOWED_KEYS
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
#cols, #db, #indexes, #sep_col, #sep_database, #sep_index, #sep_table, #sep_val, #tables
Instance Method Summary collapse
-
#close ⇒ Object
Closes the connection threadsafe.
-
#initialize(db) ⇒ 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
#count, #delete, #escape, #escape_column, #escape_database, #escape_index, #escape_table, from_object, #insert, #insert_multi, #select, #single, #sql_make_where, #sqlval, #supports_multiple_databases?, #transaction
Constructor Details
#initialize(db) ⇒ JdbcDriver
Returns a new instance of JdbcDriver.
4 5 6 7 8 |
# File 'lib/baza/jdbc_driver.rb', line 4 def initialize(db) @java_rs_data = {} @mutex = ::Mutex.new super end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
2 3 4 |
# File 'lib/baza/jdbc_driver.rb', line 2 def conn @conn end |
#conns ⇒ Object (readonly)
Returns the value of attribute conns.
2 3 4 |
# File 'lib/baza/jdbc_driver.rb', line 2 def conns @conns end |
Instance Method Details
#close ⇒ Object
Closes the connection threadsafe.
43 44 45 |
# File 'lib/baza/jdbc_driver.rb', line 43 def close @mutex.synchronize { @conn.close } end |
#query(str) ⇒ Object
Executes a query and returns the result.
21 22 23 24 25 |
# File 'lib/baza/jdbc_driver.rb', line 21 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.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/baza/jdbc_driver.rb', line 28 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 @db.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.
11 12 13 14 15 16 17 18 |
# File 'lib/baza/jdbc_driver.rb', line 11 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 |