Class: VertxSqlClient::SqlConnection

Inherits:
SqlClient
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb

Overview

A connection to database server.

Direct Known Subclasses

VertxMysqlClient::MySQLConnection, VertxPgClient::PgConnection

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 23

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

+ (Object) j_api_type


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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


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

def self.j_class
  Java::IoVertxSqlclient::SqlConnection.java_class
end

+ (Object) unwrap(obj)


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

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

+ (Object) wrap(obj)


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

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

Instance Method Details

- (::VertxSqlClient::Transaction) begin

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

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

Returns:

Raises:

  • (ArgumentError)

74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 74

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

- (void) close

This method returns an undefined value.

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

Raises:

  • (ArgumentError)

89
90
91
92
93
94
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 89

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

- (self) close_handler { ... }

Set an handler called when the connection is closed.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

62
63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 62

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) exception_handler { ... }

Set an handler called with connection errors.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

52
53
54
55
56
57
58
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 52

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) prepare(sql = nil) { ... }

Create a prepared query.

Parameters:

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

Yields:

  • the handler notified with the prepared query asynchronously

Returns:

  • (self)

Raises:

  • (ArgumentError)

42
43
44
45
46
47
48
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 42

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::PreparedQuery) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling prepare(#{sql})"
end

- (self) prepared_batch(sql = nil, batch = nil) { ... }

Parameters:

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

123
124
125
126
127
128
129
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 123

def prepared_batch(sql=nil,batch=nil)
  if sql.class == String && batch.class == Array && block_given?
    @j_del.java_method(:preparedBatch, [Java::java.lang.String.java_class,Java::JavaUtil::List.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,batch.map { |element| element.j_del },(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling prepared_batch(#{sql},#{batch})"
end

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

Parameters:

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

99
100
101
102
103
104
105
106
107
108
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 99

def prepared_query(sql=nil,arguments=nil)
  if sql.class == String && block_given? && arguments == nil
    @j_del.java_method(:preparedQuery, [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::RowSet) : nil) }))
    return self
  elsif sql.class == String && arguments.class.method_defined?(:j_del) && block_given?
    @j_del.java_method(:preparedQuery, [Java::java.lang.String.java_class,Java::IoVertxSqlclient::Tuple.java_class,Java::IoVertxCore::Handler.java_class]).call(sql,arguments.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling prepared_query(#{sql},#{arguments})"
end

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

Parameters:

  • sql (String) (defaults to: nil)

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

112
113
114
115
116
117
118
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 112

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 ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxSqlClient::RowSet) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling query(#{sql})"
end

- (true, false) ssl?

Returns whether the connection uses SSL

Returns:

  • (true, false)
    whether the connection uses SSL

Raises:

  • (ArgumentError)

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

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