Class List Method List File List

# Class: VertxSqlClient::SqlClient

Inherits:
  Object
  - Object
  - VertxSqlClient::SqlClient
  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)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) close
  Close the client and release the associated resources.
- - (self) prepared_batch(sql = nil, batch = nil) { ... }
  Prepare and execute a createBatch.
- - (self) prepared_query(sql = nil, arguments = nil) { ... }
  Prepare and execute a query.
- - (self) query(sql = nil) { ... }
  Execute a simple query.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

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

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

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

### + (`Object`) unwrap(obj)

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

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

### + (`Object`) wrap(obj)

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

    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`)

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

    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`)

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

    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) : 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`)

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

    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) : 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) : 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`)

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

    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) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling query(#{sql})"
    end