Class: VertxJdbc::JDBCClient
- Inherits:
-
VertxSql::SQLClient
- Object
- VertxSql::SQLClient
- VertxJdbc::JDBCClient
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb
Overview
An asynchronous client interface for interacting with a JDBC compliant database
Constant Summary
- @@j_api_type =
Object.new
Class Method Summary (collapse)
- + (Boolean) accept?(obj)
-
+ (::VertxJdbc::JDBCClient) create_non_shared(vertx = nil, config = nil)
Create a JDBC client which maintains its own data source.
-
+ (::VertxJdbc::JDBCClient) create_shared(vertx = nil, config = nil, dataSourceName = nil)
Create a JDBC client which shares its data source with any other JDBC clients created with the same data source name.
-
+ (Object) DEFAULT_DS_NAME
The name of the default data source.
-
+ (Object) DEFAULT_PROVIDER_CLASS
The default data source provider is C3P0.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)
Instance Method Summary (collapse)
-
- (self) call(sql = nil) { ... }
Calls the given SQL PROCEDURE which returns the result from the procedure.
-
- (self) call_with_params(sql = nil, params = nil, outputs = nil) { ... }
Calls the given SQL PROCEDURE which returns the result from the procedure.
-
- (void) close { ... }
Close the client and release all resources.
-
- (self) get_connection { ... }
Returns a connection that can be used to perform SQL operations on.
-
- (self) query(sql = nil) { ... }
Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL statement and returns it back after the execution.
-
- (self) query_single(sql = nil) { ... }
Execute a one shot SQL statement that returns a single SQL row.
-
- (self) query_single_with_params(sql = nil, arguments = nil) { ... }
Execute a one shot SQL statement with arguments that returns a single SQL row.
-
- (self) query_stream(sql = nil) { ... }
Executes the given SQL SELECT statement which returns the results of the query as a read stream.
-
- (self) query_stream_with_params(sql = nil, params = nil) { ... }
Executes the given SQL SELECT statement which returns the results of the query as a read stream.
-
- (self) query_with_params(sql = nil, arguments = nil) { ... }
Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL prepared statement and returns it back after the execution.
-
- (self) update(sql = nil) { ... }
Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.
-
- (self) update_with_params(sql = nil, params = nil) { ... }
Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters.
Class Method Details
+ (Boolean) accept?(obj)
21 22 23 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 21 def @@j_api_type.accept?(obj) obj.class == JDBCClient end |
+ (::VertxJdbc::JDBCClient) create_non_shared(vertx = nil, config = nil)
Create a JDBC client which maintains its own data source.
195 196 197 198 199 200 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 195 def self.create_non_shared(vertx=nil,config=nil) if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtJdbc::JDBCClient.java_method(:createNonShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxJdbc::JDBCClient) end raise ArgumentError, "Invalid arguments when calling create_non_shared(#{vertx},#{config})" end |
+ (::VertxJdbc::JDBCClient) create_shared(vertx = nil, config = nil, dataSourceName = nil)
Create a JDBC client which shares its data source with any other JDBC clients created with the same
data source name
207 208 209 210 211 212 213 214 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 207 def self.create_shared(vertx=nil,config=nil,dataSourceName=nil) if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? && dataSourceName == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtJdbc::JDBCClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxJdbc::JDBCClient) elsif vertx.class.method_defined?(:j_del) && config.class == Hash && dataSourceName.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtJdbc::JDBCClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config),dataSourceName),::VertxJdbc::JDBCClient) end raise ArgumentError, "Invalid arguments when calling create_shared(#{vertx},#{config},#{dataSourceName})" end |
+ (Object) DEFAULT_DS_NAME
The name of the default data source
220 221 222 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 220 def self.DEFAULT_DS_NAME Java::IoVertxExtJdbc::JDBCClient.DEFAULT_DS_NAME end |
+ (Object) DEFAULT_PROVIDER_CLASS
The default data source provider is C3P0
216 217 218 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 216 def self.DEFAULT_PROVIDER_CLASS Java::IoVertxExtJdbc::JDBCClient.DEFAULT_PROVIDER_CLASS end |
+ (Object) j_api_type
30 31 32 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 30 def self.j_api_type @@j_api_type end |
+ (Object) j_class
33 34 35 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 33 def self.j_class Java::IoVertxExtJdbc::JDBCClient.java_class end |
+ (Object) unwrap(obj)
27 28 29 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 27 def @@j_api_type.unwrap(obj) obj.j_del end |
+ (Object) wrap(obj)
24 25 26 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 24 def @@j_api_type.wrap(obj) JDBCClient.new(obj) end |
Instance Method Details
- (self) call(sql = nil) { ... }
Calls the given SQL
PROCEDURE
which returns the result from the procedure.
163 164 165 166 167 168 169 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 163 def call(sql=nil) if sql.class == String && block_given? @j_del.java_method(:call, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling call(#{sql})" end |
- (self) call_with_params(sql = nil, params = nil, outputs = nil) { ... }
Calls the given SQL
PROCEDURE
which returns the result from the procedure.
The index of params and outputs are important for both arrays, for example when dealing with a prodecure that
takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:
params = [VALUE1, VALUE2, null]
outputs = [null, null, "VARCHAR"]
184 185 186 187 188 189 190 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 184 def call_with_params(sql=nil,params=nil,outputs=nil) if sql.class == String && params.class == Array && outputs.class == Array && block_given? @j_del.java_method(:callWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),::Vertx::Util::Utils.to_json_array(outputs),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling call_with_params(#{sql},#{params},#{outputs})" end |
- (void) close { ... }
This method returns an undefined value.
Close the client and release all resources. Call the handler when close is complete.
78 79 80 81 82 83 84 85 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 78 def close if !block_given? return @j_del.java_method(:close, []).call() elsif block_given? return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) end raise ArgumentError, "Invalid arguments when calling close()" end |
- (self) get_connection { ... }
Returns a connection that can be used to perform SQL operations on. It's important to remember
to close the connection when you are done, so it is returned to the pool.
67 68 69 70 71 72 73 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 67 def get_connection if block_given? @j_del.java_method(:getConnection, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLConnection) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling get_connection()" end |
- (self) query(sql = nil) { ... }
Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL
statement and returns it back after the execution.
91 92 93 94 95 96 97 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 91 def query(sql=nil) if sql.class == String && block_given? @j_del.java_method(:query, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query(#{sql})" end |
- (self) query_single(sql = nil) { ... }
Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by
getting a connection from the pool (this object) and return it back after the execution. Only the first result
from the result set is returned.
42 43 44 45 46 47 48 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 42 def query_single(sql=nil) if sql.class == String && block_given? @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query_single(#{sql})" end |
- (self) query_single_with_params(sql = nil, arguments = nil) { ... }
Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the
boilerplate code by getting a connection from the pool (this object) and return it back after the execution.
Only the first result from the result set is returned.
56 57 58 59 60 61 62 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 56 def query_single_with_params(sql=nil,arguments=nil) if sql.class == String && arguments.class == Array && block_given? @j_del.java_method(:querySingleWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(arguments),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query_single_with_params(#{sql},#{arguments})" end |
- (self) query_stream(sql = nil) { ... }
Executes the given SQL
SELECT
statement which returns the results of the query as a read stream.
102 103 104 105 106 107 108 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 102 def query_stream(sql=nil) if sql.class == String && block_given? @j_del.java_method(:queryStream, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query_stream(#{sql})" end |
- (self) query_stream_with_params(sql = nil, params = nil) { ... }
Executes the given SQL
SELECT
statement which returns the results of the query as a read stream.
114 115 116 117 118 119 120 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 114 def query_stream_with_params(sql=nil,params=nil) if sql.class == String && params.class == Array && block_given? @j_del.java_method(:queryStreamWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query_stream_with_params(#{sql},#{params})" end |
- (self) query_with_params(sql = nil, arguments = nil) { ... }
Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL
prepared statement and returns it back after the execution.
127 128 129 130 131 132 133 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 127 def query_with_params(sql=nil,arguments=nil) if sql.class == String && arguments.class == Array && block_given? @j_del.java_method(:queryWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(arguments),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling query_with_params(#{sql},#{arguments})" end |
- (self) update(sql = nil) { ... }
Executes the given SQL statement which may be an
INSERT
, UPDATE
, or DELETE
statement.
139 140 141 142 143 144 145 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 139 def update(sql=nil) if sql.class == String && block_given? @j_del.java_method(:update, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling update(#{sql})" end |
- (self) update_with_params(sql = nil, params = nil) { ... }
Executes the given prepared statement which may be an
INSERT
, UPDATE
, or DELETE
statement with the given parameters
152 153 154 155 156 157 158 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 152 def update_with_params(sql=nil,params=nil) if sql.class == String && params.class == Array && block_given? @j_del.java_method(:updateWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling update_with_params(#{sql},#{params})" end |