Class List Method List File List

# Class: VertxSql::SQLConnection

Inherits:
  Object
  - Object
  - VertxSql::SQLConnection
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb

## Overview

Represents a connection to a SQL database

## Instance Method Summary (collapse)

- - (void) close { ... }
  Closes the connection.
- - (self) commit { ... }
  Commits all changes made since the previous commit/rollback.
- - (self) execute(sql = nil) { ... }
  Executes the given SQL statement.
- - (self) query(sql = nil) { ... }
  Executes the given SQL SELECT statement which returns the results of the query.
- - (self) query_with_params(sql = nil, params = nil) { ... }
  Executes the given SQL SELECT prepared statement which returns the results of the query.
- - (self) rollback { ... }
  Rolls back all changes made since the previous commit/rollback.
- - (self) set_auto_commit(autoCommit = nil) { ... }
  Sets the auto commit flag for this connection.
- - (self) update(sql = nil) { ... }
  Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.
- - (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.

## Instance Method Details

### - (`void`) close { ... }

This method returns an undefined value.

Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

Yields:

- the handler called when this operation completes.

Raises:

- (`ArgumentError`)

    89
    90
    91
    92
    93
    94
    95
    96
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 89

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

Commits all changes made since the previous commit/rollback.

Yields:

- the handler called when this operation completes.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    100
    101
    102
    103
    104
    105
    106
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 100

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

### - (`self`) execute(sql = nil) { ... }

Executes the given SQL statement

Parameters:

- sql (`String`) (defaults to: `nil`) —
  the SQL to execute. For example `CREATE TABLE IF EXISTS table ...`

Yields:

- the handler which is called once this operation completes.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    31
    32
    33
    34
    35
    36
    37
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 31

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

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

Executes the given SQL `SELECT` statement which returns the results of the query.

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 ResultSet.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    42
    43
    44
    45
    46
    47
    48
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 42

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

Executes the given SQL `SELECT` prepared statement which returns the results of the query.

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 ResultSet.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    60
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 54

    def query_with_params(sql=nil,params=nil)
      if sql.class == String && params.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(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 query_with_params(sql,params)"
    end

### - (`self`) rollback { ... }

Rolls back all changes made since the previous commit/rollback.

Yields:

- the handler called when this operation completes.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    110
    111
    112
    113
    114
    115
    116
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 110

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

### - (`self`) set_auto_commit(autoCommit = nil) { ... }

Sets the auto commit flag for this connection. True by default.

Parameters:

- autoCommit (`true`, `false`) (defaults to: `nil`) —
  the autoCommit flag, true by default.

Yields:

- the handler which is called once this operation completes.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    20
    21
    22
    23
    24
    25
    26
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 20

    def set_auto_commit(autoCommit=nil)
      if (autoCommit.class == TrueClass || autoCommit.class == FalseClass) && block_given?
        @j_del.java_method(:setAutoCommit, [Java::boolean.java_class,Java::IoVertxCore::Handler.java_class]).call(autoCommit,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_auto_commit(autoCommit)"
    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`)

    66
    67
    68
    69
    70
    71
    72
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 66

    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`)

    79
    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-sql-common/src/main/resources/vertx-sql/sql_connection.rb', line 79

    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