Class: VertxMysqlClient::MySQLConnection

Inherits:
VertxSqlClient::SqlConnection show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb

Overview

A connection to MySQL server.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 26

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

+ (void) connect(vertx, connectOptions, handler) { ... } + (void) connect(vertx, connectionUri, handler) { ... }

This method returns an undefined value.

Like #connect with options build from connectionUri.

Overloads:

  • + (void) connect(vertx, connectOptions, handler) { ... }

    Parameters:

    • vertx (::Vertx::Vertx)
      the vertx instance
    • connectOptions (Hash)
      the options for the connection

    Yields:

    • the handler called with the connection or the failure
  • + (void) connect(vertx, connectionUri, handler) { ... }

    Parameters:

    Yields:

Raises:

  • (ArgumentError)


96
97
98
99
100
101
102
103
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 96

def self.connect(param_1=nil,param_2=nil)
  if param_1.class.method_defined?(:j_del) && param_2.class == Hash && block_given?
    return Java::IoVertxMysqlclient::MySQLConnection.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxMysqlclient::MySQLConnectOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,Java::IoVertxMysqlclient::MySQLConnectOptions.new(::Vertx::Util::Utils.to_json_object(param_2)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxMysqlClient::MySQLConnection) : nil) }))
  elsif param_1.class.method_defined?(:j_del) && param_2.class == String && block_given?
    return Java::IoVertxMysqlclient::MySQLConnection.java_method(:connect, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxMysqlClient::MySQLConnection) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling connect(#{param_1},#{param_2})"
end

+ (Object) j_api_type



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 35

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 38

def self.j_class
  Java::IoVertxMysqlclient::MySQLConnection.java_class
end

+ (Object) unwrap(obj)



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 32

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

+ (Object) wrap(obj)



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 29

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

Instance Method Details

- (::VertxSqlClient::Transaction) begin

Begin a transaction and returns a for controlling and tracking this transaction.

When the connection is explicitely closed, any inflight transaction is rollbacked.

Returns:

Raises:

  • (ArgumentError)


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

def begin
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:begin, []).call(),::VertxSqlClient::Transaction)
  end
  raise ArgumentError, "Invalid arguments when calling begin()"
end

- (self) change_user(options = nil) { ... }

Send a CHANGE_USER command to change the user of the current connection, this operation will also reset connection state.

Parameters:

  • options (Hash) (defaults to: nil)
    authentication options

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


198
199
200
201
202
203
204
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 198

def change_user(options=nil)
  if options.class == Hash && block_given?
    @j_del.java_method(:changeUser, [Java::IoVertxMysqlclient::MySQLAuthOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxMysqlclient::MySQLAuthOptions.new(::Vertx::Util::Utils.to_json_object(options)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling change_user(#{options})"
end

- (void) close

This method returns an undefined value.

Close the current connection after all the pending commands have been processed.

Raises:

  • (ArgumentError)


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

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (self) close_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


125
126
127
128
129
130
131
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 125

def close_handler
  if block_given?
    @j_del.java_method(:closeHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling close_handler()"
end

- (self) debug { ... }

Send a DEBUG command to dump debug information to the server's stdout.

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)


187
188
189
190
191
192
193
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 187

def debug
  if block_given?
    @j_del.java_method(:debug, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling debug()"
end

- (self) exception_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


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

def exception_handler
  if block_given?
    @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling exception_handler()"
end

- (self) get_internal_statistics { ... }

Send a STATISTICS command to get a human readable string of the server internal status.

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)


156
157
158
159
160
161
162
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 156

def get_internal_statistics
  if block_given?
    @j_del.java_method(:getInternalStatistics, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling get_internal_statistics()"
end

- (self) ping { ... }

Send a PING command to check if the server is alive.

Yields:

  • the handler notified when the server responses to client

Returns:

  • (self)

Raises:

  • (ArgumentError)


135
136
137
138
139
140
141
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 135

def ping
  if block_given?
    @j_del.java_method(:ping, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling ping()"
end

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

Parameters:

  • sql (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


107
108
109
110
111
112
113
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 107

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

- (::VertxSqlClient::PreparedQuery) prepared_query(sql = nil)

Create a prepared query, one of the or methods must be called to execute the query.

Parameters:

  • sql (String) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)


54
55
56
57
58
59
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 54

def prepared_query(sql=nil)
  if sql.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class]).call(sql),::VertxSqlClient::PreparedQuery,::VertxSqlClient::RowSet.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql})"
end

- (::VertxSqlClient::Query) query(sql = nil)

Create a query, the method must be called to execute the query.

Parameters:

  • sql (String) (defaults to: nil)

Returns:

Raises:

  • (ArgumentError)


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

def query(sql=nil)
  if sql.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:query, [Java::java.lang.String.java_class]).call(sql),::VertxSqlClient::Query,::VertxSqlClient::RowSet.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end

- (self) reset_connection { ... }

Send a RESET_CONNECTION command to reset the session state.

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)


177
178
179
180
181
182
183
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 177

def reset_connection
  if block_given?
    @j_del.java_method(:resetConnection, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling reset_connection()"
end

- (self) set_option(option = nil) { ... }

Send a SET_OPTION command to set options for the current connection.

Parameters:

  • option (:MYSQL_OPTION_MULTI_STATEMENTS_ON, :MYSQL_OPTION_MULTI_STATEMENTS_OFF) (defaults to: nil)
    the options to set

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)


167
168
169
170
171
172
173
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 167

def set_option(option=nil)
  if option.class == Symbol && block_given?
    @j_del.java_method(:setOption, [Java::IoVertxMysqlclient::MySQLSetOption.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxMysqlclient::MySQLSetOption.valueOf(option.to_s),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_option(#{option})"
end

- (self) specify_schema(schemaName = nil) { ... }

Send a INIT_DB command to change the default schema of the connection.

Parameters:

  • schemaName (String) (defaults to: nil)
    name of the schema to change to

Yields:

  • the handler notified with the execution result

Returns:

  • (self)

Raises:

  • (ArgumentError)


146
147
148
149
150
151
152
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 146

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

- (true, false) ssl?

Returns whether the connection uses SSL

Returns:

  • (true, false)
    whether the connection uses SSL

Raises:

  • (ArgumentError)


72
73
74
75
76
77
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mysql-client/my_sql_connection.rb', line 72

def ssl?
  if !block_given?
    return @j_del.java_method(:isSSL, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling ssl?()"
end