Class: VertxSql::SQLConnection

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb

Overview

Represents a connection to a SQL database

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


18
19
20
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 18

def @@j_api_type.accept?(obj)
  obj.class == SQLConnection
end

+ (Object) j_api_type



27
28
29
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 27

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



30
31
32
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 30

def self.j_class
  Java::IoVertxExtSql::SQLConnection.java_class
end

+ (Object) unwrap(obj)



24
25
26
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 24

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



21
22
23
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 21

def @@j_api_type.wrap(obj)
  SQLConnection.new(obj)
end

Instance Method Details

- (self) batch(sqlStatements = nil) { ... }

Batch simple SQL strings and execute the batch where the async result contains a array of Integers.

Parameters:

  • sqlStatements (Array<String>) (defaults to: nil)
    sql statement

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


205
206
207
208
209
210
211
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 205

def batch(sqlStatements=nil)
  if sqlStatements.class == Array && block_given?
    @j_del.java_method(:batch, [Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sqlStatements.map { |element| element },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt } : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling batch(#{sqlStatements})"
end

- (self) batch_callable_with_params(sqlStatement = nil, inArgs = nil, outArgs = nil) { ... }

Batch a callable statement with all entries from the args list. Each entry is a batch. The size of the lists inArgs and outArgs MUST be the equal. The operation completes with the execution of the batch where the async result contains a array of Integers.

Parameters:

  • sqlStatement (String) (defaults to: nil)
    sql statement
  • inArgs (Array<Array<String,Object>>) (defaults to: nil)
    the callable statement input arguments
  • outArgs (Array<Array<String,Object>>) (defaults to: nil)
    the callable statement output arguments

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


233
234
235
236
237
238
239
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 233

def batch_callable_with_params(sqlStatement=nil,inArgs=nil,outArgs=nil)
  if sqlStatement.class == String && inArgs.class == Array && outArgs.class == Array && block_given?
    @j_del.java_method(:batchCallableWithParams, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sqlStatement,inArgs.map { |element| ::Vertx::Util::Utils.to_json_array(element) },outArgs.map { |element| ::Vertx::Util::Utils.to_json_array(element) },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt } : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling batch_callable_with_params(#{sqlStatement},#{inArgs},#{outArgs})"
end

- (self) batch_with_params(sqlStatement = nil, args = nil) { ... }

Batch a prepared statement with all entries from the args list. Each entry is a batch. The operation completes with the execution of the batch where the async result contains a array of Integers.

Parameters:

  • sqlStatement (String) (defaults to: nil)
    sql statement
  • args (Array<Array<String,Object>>) (defaults to: nil)
    the prepared statement arguments

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


218
219
220
221
222
223
224
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 218

def batch_with_params(sqlStatement=nil,args=nil)
  if sqlStatement.class == String && args.class == Array && block_given?
    @j_del.java_method(:batchWithParams, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sqlStatement,args.map { |element| ::Vertx::Util::Utils.to_json_array(element) },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt } : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling batch_with_params(#{sqlStatement},#{args})"
end

- (self) call(sql = nil) { ... }

Calls the given SQL PROCEDURE which returns the result from the procedure.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example {call getEmpName}.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)

Raises:

  • (ArgumentError)


130
131
132
133
134
135
136
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 130

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"]

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example {call getEmpName (?, ?)}.
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.
  • outputs (Array<String,Object>) (defaults to: nil)
    these are the outputs to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)

Raises:

  • (ArgumentError)


151
152
153
154
155
156
157
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 151

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.

Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

Yields:

  • the handler called when this operation completes.

Raises:

  • (ArgumentError)


161
162
163
164
165
166
167
168
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 161

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) commit { ... }

Commits all changes made since the previous commit/rollback.

Yields:

  • the handler called when this operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


172
173
174
175
176
177
178
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 172

def commit
  if block_given?
    @j_del.java_method(:commit, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling commit()"
end

- (self) execute(sql = nil) { ... }

Executes the given SQL statement

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example CREATE TABLE IF EXISTS table ...

Yields:

  • the handler which is called once this operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 48

def execute(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:execute, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling execute(#{sql})"
end

- (self) get_transaction_isolation { ... }

Attempts to return the transaction isolation level for this Connection object to the one given.

Yields:

  • the handler called when this operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


256
257
258
259
260
261
262
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 256

def get_transaction_isolation
  if block_given?
    @j_del.java_method(:getTransactionIsolation, [Java::IoVertxCore::Handler.java_class]).call(nil)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling get_transaction_isolation()"
end

- (self) query(sql = nil) { ... }

Executes the given SQL SELECT statement which returns the results of the query.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)

Raises:

  • (ArgumentError)


59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 59

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_stream(sql = nil) { ... }

Executes the given SQL SELECT statement which returns the results of the query as a read stream.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....

Yields:

  • the handler which is called once the operation completes. It will return a SQLRowStream.

Returns:

  • (self)

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 70

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.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a SQLRowStream.

Returns:

  • (self)

Raises:

  • (ArgumentError)


94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 94

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, params = nil) { ... }

Executes the given SQL SELECT prepared statement which returns the results of the query.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)

Raises:

  • (ArgumentError)


82
83
84
85
86
87
88
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 82

def query_with_params(sql=nil,params=nil)
  if sql.class == String && params.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(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 query_with_params(#{sql},#{params})"
end

- (self) rollback { ... }

Rolls back all changes made since the previous commit/rollback.

Yields:

  • the handler called when this operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


182
183
184
185
186
187
188
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 182

def rollback
  if block_given?
    @j_del.java_method(:rollback, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling rollback()"
end

- (self) set_auto_commit(autoCommit = nil) { ... }

Sets the auto commit flag for this connection. True by default.

Parameters:

  • autoCommit (true, false) (defaults to: nil)
    the autoCommit flag, true by default.

Yields:

  • the handler which is called once this operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 37

def set_auto_commit(autoCommit=nil)
  if (autoCommit.class == TrueClass || autoCommit.class == FalseClass) && block_given?
    @j_del.java_method(:setAutoCommit, [Java::boolean.java_class,Java::IoVertxCore::Handler.java_class]).call(autoCommit,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_auto_commit(#{autoCommit})"
end

- (self) set_query_timeout(timeoutInSeconds = nil)

Sets a connection wide query timeout. It can be over written at any time and becomes active on the next query call.

Parameters:

  • timeoutInSeconds (Fixnum) (defaults to: nil)
    the max amount of seconds the query can take to execute.

Returns:

  • (self)

Raises:

  • (ArgumentError)


194
195
196
197
198
199
200
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 194

def set_query_timeout(timeoutInSeconds=nil)
  if timeoutInSeconds.class == Fixnum && !block_given?
    @j_del.java_method(:setQueryTimeout, [Java::int.java_class]).call(timeoutInSeconds)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_query_timeout(#{timeoutInSeconds})"
end

- (self) set_transaction_isolation(isolation = nil) { ... }

Attempts to change the transaction isolation level for this Connection object to the one given. The constants defined in the interface Connection are the possible transaction isolation levels.

Parameters:

  • isolation (:READ_UNCOMMITTED, :READ_COMMITTED, :REPEATABLE_READ, :SERIALIZABLE, :NONE) (defaults to: nil)
    the level of isolation

Yields:

  • the handler called when this operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


246
247
248
249
250
251
252
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 246

def set_transaction_isolation(isolation=nil)
  if isolation.class == Symbol && block_given?
    @j_del.java_method(:setTransactionIsolation, [Java::IoVertxExtSql::TransactionIsolation.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxExtSql::TransactionIsolation.valueOf(isolation.to_s),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_transaction_isolation(#{isolation})"
end

- (self) update(sql = nil) { ... }

Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example INSERT INTO table ...

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


106
107
108
109
110
111
112
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 106

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

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example INSERT INTO table ...
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


119
120
121
122
123
124
125
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-sql/sql_connection.rb', line 119

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