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)

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.accept?(obj)
  obj.class == SqlConnection
end

+ (Object) j_api_type


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_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-sql-client/sql_connection.rb', line 38

def self.j_class
  Java::IoVertxSqlclient::SqlConnection.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-sql-client/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-sql-client/sql_connection.rb', line 29

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)

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

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)

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

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)

84
85
86
87
88
89
90
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 84

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

- (::VertxSqlClient::DatabaseMetadata) database_metadata

Returns The static metadata about the backend database server for this connection

Returns:

Raises:

  • (ArgumentError)

118
119
120
121
122
123
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/sql_connection.rb', line 118

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

- (self) exception_handler { ... }

Set an handler called with connection errors.

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

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

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)

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

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 Query#execute or PreparedQuery#execute_batch 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-sql-client/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 Query#execute 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-sql-client/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

- (true, false) ssl?

Returns whether the connection uses SSL

Returns:

  • (true, false)
    whether the connection uses SSL

Raises:

  • (ArgumentError)

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 103

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