Class: VertxSqlClient::SqlClient

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb

Overview

Defines the client operations with a database server.

Direct Known Subclasses

Pool, SqlConnection, Transaction

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

20
21
22
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 20

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

+ (Object) j_api_type


29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 29

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 32

def self.j_class
  Java::IoVertxSqlclient::SqlClient.java_class
end

+ (Object) unwrap(obj)


26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 26

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

+ (Object) wrap(obj)


23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 23

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

Instance Method Details

- (void) close

This method returns an undefined value.

Close the client and release the associated resources.

Raises:

  • (ArgumentError)

75
76
77
78
79
80
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 75

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (self) prepared_batch(sql = nil, batch = nil) { ... }

Prepare and execute a createBatch.

Parameters:

  • sql (String) (defaults to: nil)
    the prepared query SQL
  • batch (Array<::VertxSqlClient::Tuple>) (defaults to: nil)
    the batch of tuples

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)

66
67
68
69
70
71
72
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 66

def prepared_batch(sql=nil,batch=nil)
  if sql.class == String && batch.class == Array && block_given?
    @j_del.java_method(:preparedBatch, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,batch.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling prepared_batch(#{sql},#{batch})"
end

- (self) prepared_query(sql = nil, arguments = nil) { ... }

Prepare and execute a query.

Parameters:

  • sql (String) (defaults to: nil)
    the prepared query SQL
  • arguments (::VertxSqlClient::Tuple) (defaults to: nil)
    the list of arguments

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)

51
52
53
54
55
56
57
58
59
60
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 51

def prepared_query(sql=nil,arguments=nil)
  if sql.class == String && block_given? && arguments == nil
    @j_del.java_method(:preparedQuery, [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,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
    return self
  elsif sql.class == String && arguments.class.method_defined?(:j_del) && block_given?
    @j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::IoVertxSqlclient::Tuple.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,arguments.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql},#{arguments})"
end

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

Execute a simple query.

Parameters:

  • sql (String) (defaults to: nil)
    the query SQL

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)

39
40
41
42
43
44
45
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_client.rb', line 39

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 ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet,::VertxSqlClient::Row.j_api_type) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end