Class List Method List File List

# Class: VertxJdbc::JDBCClient

Inherits:
  Object
  - Object
  - VertxJdbc::JDBCClient
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-jdbc-client/src/main/resources/vertx-jdbc/jdbc_client.rb

## Overview

An asynchronous client interface for interacting with a JDBC compliant database

## Class Method Summary (collapse)

- + (::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.

## Instance Method Summary (collapse)

- - (void) close
  Close the client.
- - (self) get_connection { ... }
  Returns a connection that can be used to perform SQL operations on.

## Class Method Details

### + (`::VertxJdbc::JDBCClient`) create_non_shared(vertx = nil, config = nil)

Create a JDBC client which maintains its own data source.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vert.x instance
- config (`Hash{String => Object}`) (defaults to: `nil`) —
  the configuration

Returns:

- (`::VertxJdbc::JDBCClient`) —
  the client

Raises:

- (`ArgumentError`)

    22
    23
    24
    25
    26
    27
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-jdbc-client/src/main/resources/vertx-jdbc/jdbc_client.rb', line 22

    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

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vert.x instance
- config (`Hash{String => Object}`) (defaults to: `nil`) —
  the configuration
- dataSourceName (`String`) (defaults to: `nil`) —
  the data source name

Returns:

- (`::VertxJdbc::JDBCClient`) —
  the client

Raises:

- (`ArgumentError`)

    34
    35
    36
    37
    38
    39
    40
    41
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-jdbc-client/src/main/resources/vertx-jdbc/jdbc_client.rb', line 34

    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

## Instance Method Details

### - (`void`) close

This method returns an undefined value.

Close the client

Raises:

- (`ArgumentError`)

    55
    56
    57
    58
    59
    60
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-jdbc-client/src/main/resources/vertx-jdbc/jdbc_client.rb', line 55

    def close
      if !block_given?
        return @j_del.java_method(:close, []).call()
      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.

Yields:

- the handler which is called when the `JdbcConnection` object is ready for use.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    46
    47
    48
    49
    50
    51
    52
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-jdbc-client/src/main/resources/vertx-jdbc/jdbc_client.rb', line 46

    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