Class: VertxMysqlPostgresql::PostgreSQLClient

Inherits:
AsyncSQLClient show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb

Overview

Represents an PostgreSQL client

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

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-mysql-postgresql/postgre_sql_client.rb', line 22

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

+ (::VertxMysqlPostgresql::AsyncSQLClient) create_non_shared(vertx = nil, config = nil)

Create a PostgreSQL client which maintains its own pool.

Parameters:

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

Returns:

Raises:

  • (ArgumentError)


196
197
198
199
200
201
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 196

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::IoVertxExtAsyncsql::PostgreSQLClient.java_method(:createNonShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxMysqlPostgresql::AsyncSQLClient)
  end
  raise ArgumentError, "Invalid arguments when calling create_non_shared(#{vertx},#{config})"
end

+ (::VertxMysqlPostgresql::AsyncSQLClient) create_shared(vertx = nil, config = nil, poolName = nil)

Create a PostgreSQL client which shares its pool with any other MySQL clients created with the same pool name.

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vert.x instance
  • config (Hash{String => Object}) (defaults to: nil)
    the configuration
  • poolName (String) (defaults to: nil)
    the pool name

Returns:

Raises:

  • (ArgumentError)


207
208
209
210
211
212
213
214
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 207

def self.create_shared(vertx=nil,config=nil,poolName=nil)
  if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? && poolName == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAsyncsql::PostgreSQLClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxMysqlPostgresql::AsyncSQLClient)
  elsif vertx.class.method_defined?(:j_del) && config.class == Hash && poolName.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAsyncsql::PostgreSQLClient.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),poolName),::VertxMysqlPostgresql::AsyncSQLClient)
  end
  raise ArgumentError, "Invalid arguments when calling create_shared(#{vertx},#{config},#{poolName})"
end

+ (Object) DEFAULT_CHARSET

The default charset.


240
241
242
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 240

def self.DEFAULT_CHARSET
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_CHARSET
end

+ (Object) DEFAULT_CONNECT_TIMEOUT

The default timeout for connect.


244
245
246
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 244

def self.DEFAULT_CONNECT_TIMEOUT
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_CONNECT_TIMEOUT
end

+ (Object) DEFAULT_DATABASE

The default database name.


228
229
230
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 228

def self.DEFAULT_DATABASE
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_DATABASE
end

+ (Object) DEFAULT_DS_NAME

The default name used for the PostGreSQL pool.


216
217
218
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 216

def self.DEFAULT_DS_NAME
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_DS_NAME
end

+ (Object) DEFAULT_HOST

The default host.


220
221
222
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 220

def self.DEFAULT_HOST
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_HOST
end

+ (Object) DEFAULT_PASSWORD

The default user password.


236
237
238
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 236

def self.DEFAULT_PASSWORD
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_PASSWORD
end

+ (Object) DEFAULT_PORT

The default port.


224
225
226
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 224

def self.DEFAULT_PORT
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_PORT
end

+ (Object) DEFAULT_TEST_TIMEOUT

The default timeout for tests.


248
249
250
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 248

def self.DEFAULT_TEST_TIMEOUT
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_TEST_TIMEOUT
end

+ (Object) DEFAULT_USER

The default database user.


232
233
234
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 232

def self.DEFAULT_USER
  Java::IoVertxExtAsyncsql::PostgreSQLClient.DEFAULT_USER
end

+ (Object) j_api_type



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_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-mysql-postgresql/postgre_sql_client.rb', line 34

def self.j_class
  Java::IoVertxExtAsyncsql::PostgreSQLClient.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-mysql-postgresql/postgre_sql_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-mysql-postgresql/postgre_sql_client.rb', line 25

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

Instance Method Details

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

Calls the given SQL PROCEDURE which returns the result from the procedure.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example {call getEmpName}.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)

Raises:

  • (ArgumentError)


164
165
166
167
168
169
170
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 164

def call(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:call, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling call(#{sql})"
end

- (self) call_with_params(sql = nil, params = nil, outputs = nil) { ... }

Calls the given SQL PROCEDURE which returns the result from the procedure. The index of params and outputs are important for both arrays, for example when dealing with a prodecure that takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:

   params = [VALUE1, VALUE2, null]
   outputs = [null, null, "VARCHAR"]

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example {call getEmpName (?, ?)}.
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.
  • outputs (Array<String,Object>) (defaults to: nil)
    these are the outputs to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a ResultSet.

Returns:

  • (self)

Raises:

  • (ArgumentError)


185
186
187
188
189
190
191
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 185

def call_with_params(sql=nil,params=nil,outputs=nil)
  if sql.class == String && params.class == Array && outputs.class == Array && block_given?
    @j_del.java_method(:callWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),::Vertx::Util::Utils.to_json_array(outputs),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling call_with_params(#{sql},#{params},#{outputs})"
end

- (void) close { ... }

This method returns an undefined value.

Close the client and release all resources. Call the handler when close is complete.

Yields:

  • the handler that will be called when close is complete

Raises:

  • (ArgumentError)


79
80
81
82
83
84
85
86
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 79

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  elsif block_given?
    return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  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)


68
69
70
71
72
73
74
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 68

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

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

Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL statement and returns it back after the execution.

Parameters:

  • sql (String) (defaults to: nil)
    the statement to execute

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


92
93
94
95
96
97
98
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 92

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 ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end

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

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) (defaults to: nil)
    the statement to execute

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 43

def query_single(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:querySingle, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query_single(#{sql})"
end

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

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) (defaults to: nil)
    the statement to execute
  • arguments (Array<String,Object>) (defaults to: nil)
    the arguments

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


57
58
59
60
61
62
63
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 57

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

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

Executes the given SQL SELECT statement which returns the results of the query as a read stream.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....

Yields:

  • the handler which is called once the operation completes. It will return a SQLRowStream.

Returns:

  • (self)

Raises:

  • (ArgumentError)


103
104
105
106
107
108
109
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 103

def query_stream(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:queryStream, [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,::VertxSql::SQLRowStream) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query_stream(#{sql})"
end

- (self) query_stream_with_params(sql = nil, params = nil) { ... }

Executes the given SQL SELECT statement which returns the results of the query as a read stream.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example SELECT * FROM table ....
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes. It will return a SQLRowStream.

Returns:

  • (self)

Raises:

  • (ArgumentError)


115
116
117
118
119
120
121
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 115

def query_stream_with_params(sql=nil,params=nil)
  if sql.class == String && params.class == Array && block_given?
    @j_del.java_method(:queryStreamWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSql::SQLRowStream) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query_stream_with_params(#{sql},#{params})"
end

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

Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL prepared statement and returns it back after the execution.

Parameters:

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

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


128
129
130
131
132
133
134
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 128

def query_with_params(sql=nil,arguments=nil)
  if sql.class == String && arguments.class == Array && block_given?
    @j_del.java_method(:queryWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(arguments),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query_with_params(#{sql},#{arguments})"
end

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

Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example INSERT INTO table ...

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


140
141
142
143
144
145
146
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 140

def update(sql=nil)
  if sql.class == String && block_given?
    @j_del.java_method(:update, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling update(#{sql})"
end

- (self) update_with_params(sql = nil, params = nil) { ... }

Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters

Parameters:

  • sql (String) (defaults to: nil)
    the SQL to execute. For example INSERT INTO table ...
  • params (Array<String,Object>) (defaults to: nil)
    these are the parameters to fill the statement.

Yields:

  • the handler which is called once the operation completes.

Returns:

  • (self)

Raises:

  • (ArgumentError)


153
154
155
156
157
158
159
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-postgresql/postgre_sql_client.rb', line 153

def update_with_params(sql=nil,params=nil)
  if sql.class == String && params.class == Array && block_given?
    @j_del.java_method(:updateWithParams, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonArray.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,::Vertx::Util::Utils.to_json_array(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling update_with_params(#{sql},#{params})"
end