Class: VertxJdbc::JDBCClient

Inherits:
VertxSql::SQLClient show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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)

Instance Method Summary (collapse)

Methods inherited from VertxSql::SQLClient

#call, #call_with_params, #close, #get_connection, #query, #query_stream, #query_stream_with_params, #query_with_params, #update, #update_with_params

Methods included from VertxSql::SQLOperations

#call, #call_with_params, #query, #query_stream, #query_stream_with_params, #query_with_params, #update, #update_with_params

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (::VertxJdbc::JDBCClient) createNonShared(vertx, config)

Create a JDBC client which maintains its own data source.

Parameters:

  • vertx (::Vertx::Vertx)
    the Vert.x instance
  • config (Hash{String => Object})
    the configuration

Returns:



113
114
115
116
117
118
119
120
121
122
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 113

def self.create_non_shared(*args)
  if args[0].class.method_defined?(:j_del) && args[1].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(args[0].j_del,::Vertx::Util::Utils.to_json_object(args[1])),::VertxJdbc::JDBCClient)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling create_non_shared(#{args[0]},#{args[1]})"
  end
end

+ (::VertxJdbc::JDBCClient) createShared(vertx, config) + (::VertxJdbc::JDBCClient) createShared(vertx, config, dataSourceName)

Create a JDBC client which shares its data source with any other JDBC clients created with the same data source name

Overloads:

  • + (::VertxJdbc::JDBCClient) createShared(vertx, config)

    Parameters:

    • vertx (::Vertx::Vertx)
      the Vert.x instance
    • config (Hash{String => Object})
      the configuration
  • + (::VertxJdbc::JDBCClient) createShared(vertx, config, dataSourceName)

    Parameters:

    • vertx (::Vertx::Vertx)
      the Vert.x instance
    • config (Hash{String => Object})
      the configuration
    • dataSourceName (String)
      the data source name

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 47

def self.create_shared(*args)
  if args[0].class.method_defined?(:j_del) && args[1].class == Hash && !block_given? && args[2] == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtJdbc::JDBCClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(args[0].j_del,::Vertx::Util::Utils.to_json_object(args[1])),::VertxJdbc::JDBCClient)
  elsif args[0].class.method_defined?(:j_del) && args[1].class == Hash && args[2].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(args[0].j_del,::Vertx::Util::Utils.to_json_object(args[1]),args[2]),::VertxJdbc::JDBCClient)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling create_shared(#{args[0]},#{args[1]},#{args[2]})"
  end
end

+ (Object) DEFAULT_DS_NAME

The name of the default data source


128
129
130
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 128

def self.DEFAULT_DS_NAME
  Java::IoVertxExtJdbc::JDBCClient.DEFAULT_DS_NAME
end

+ (Object) DEFAULT_PROVIDER_CLASS

The default data source provider is C3P0


124
125
126
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 124

def self.DEFAULT_PROVIDER_CLASS
  Java::IoVertxExtJdbc::JDBCClient.DEFAULT_PROVIDER_CLASS
end

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



34
35
36
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 34

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (self) querySingle(sql, handler) { ... }

Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

Parameters:

  • sql (String)
    the statement to execute

Yields:

  • the result handler

Returns:

  • (self)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 66

def query_single(*args)
  if args[0].class == String && true
    if (block_given?)
      @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_single(#{args[0]})"
  end
end

- (self) querySingleWithParams(sql, arguments, handler) { ... }

Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

Parameters:

  • sql (String)
    the statement to execute
  • arguments (Array<String,Object>)
    the arguments

Yields:

  • the result handler

Returns:

  • (self)


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-jdbc/jdbc_client.rb', line 91

def query_single_with_params(*args)
  if args[0].class == String && args[1].class == Array && true
    if (block_given?)
      @j_del.java_method(:querySingleWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return self
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:querySingleWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(args[0],::Vertx::Util::Utils.to_json_array(args[1]),block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling query_single_with_params(#{args[0]},#{args[1]})"
  end
end