Class: VertxSqlClient::PreparedStatement

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

Overview

A prepared statement, the statement is pre-compiled and it's more efficient to execute the statement for multiple times. In addition, this kind of statement provides protection against SQL injection attacks.

From a prepared statement you can

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (Object) j_api_type



41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_statement.rb', line 41

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) close { ... }

This method returns an undefined value.

Like #close but notifies the completionHandler when it's closed.

Yields:

Raises:

  • (ArgumentError)


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

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

- (::VertxSqlClient::RowStream) create_stream(fetch = nil, args = nil)

Execute the prepared query with a cursor and createStream the result. The createStream opens a cursor with a fetch size to fetch the results.

Note: this requires to be in a transaction, since cursors require it.

Parameters:

  • fetch (Fixnum) (defaults to: nil)
    the cursor fetch size
  • args (::VertxSqlClient::Tuple) (defaults to: nil)
    the prepared query arguments

Returns:

Raises:

  • (ArgumentError)


73
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/prepared_statement.rb', line 73

def create_stream(fetch=nil,args=nil)
  if fetch.class == Fixnum && !block_given? && args == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createStream, [Java::int.java_class]).call(fetch),::VertxSqlClient::RowStream,::VertxSqlClient::Row.j_api_type)
  elsif fetch.class == Fixnum && args.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createStream, [Java::int.java_class,Java::IoVertxSqlclient::Tuple.java_class]).call(fetch,args.j_del),::VertxSqlClient::RowStream,::VertxSqlClient::Row.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling create_stream(#{fetch},#{args})"
end

- (::VertxSqlClient::Cursor) cursor(args = nil)

Create a cursor with the provided arguments.

Parameters:

Returns:

Raises:

  • (ArgumentError)


58
59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_statement.rb', line 58

def cursor(args=nil)
  if !block_given? && args == nil
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:cursor, []).call(),::VertxSqlClient::Cursor)
  elsif args.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:cursor, [Java::IoVertxSqlclient::Tuple.java_class]).call(args.j_del),::VertxSqlClient::Cursor)
  end
  raise ArgumentError, "Invalid arguments when calling cursor(#{args})"
end

- (::VertxSqlClient::PreparedQuery) query

Create a prepared query for this statement.

Returns:

Raises:

  • (ArgumentError)


49
50
51
52
53
54
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql-client/prepared_statement.rb', line 49

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