Class List Method List File List

# Class: VertxJdbc::JDBCClient

Inherits:
  Object
  - Object
  - VertxJdbc::JDBCClient
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/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) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## 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

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

Returns:

- (`Boolean`)

    19
    20
    21
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-jdbc/jdbc_client.rb', line 19

    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.

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

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

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

    50
    51
    52
    53
    54
    55
    56
    57
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-jdbc/jdbc_client.rb', line 50

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

    28
    29
    30
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-jdbc/jdbc_client.rb', line 28

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    31
    32
    33
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-jdbc/jdbc_client.rb', line 31

    def self.j_class
      Java::IoVertxExtJdbc::JDBCClient.java_class
    end

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

    25
    26
    27
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-jdbc/jdbc_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-stack/stack-docs/target/rb/vertx-jdbc/jdbc_client.rb', line 22

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

## Instance Method Details

### - (`void`) close

This method returns an undefined value.

Close the client

Raises:

- (`ArgumentError`)

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

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

    62
    63
    64
    65
    66
    67
    68
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-jdbc/jdbc_client.rb', line 62

    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