A common asynchronous client interface for interacting with SQL compliant database

Initializer
SQLClient(SQLClient unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
callshared actual default SQLClient call(String sql, Anything(Throwable|ResultSet) handler)

Calls the given SQL PROCEDURE which returns the result from the procedure.

Parameters:
  • sql

    the SQL to execute. For example {call getEmpName}.

  • handler

    the handler which is called once the operation completes. It will return a ResultSet.

callWithParamsshared actual default SQLClient callWithParams(String sql, Array params, Array outputs, Anything(Throwable|ResultSet) handler)

Calls the given SQL PROCEDURE which returns the result from the procedure.

The index of params and outputs are important for both arrays, for example when dealing with a prodecure that takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:

   params = [VALUE1, VALUE2, null]
   outputs = [null, null, "VARCHAR"]
 
Parameters:
  • sql

    the SQL to execute. For example {call getEmpName (?, ?)}.

  • params

    these are the parameters to fill the statement.

  • outputs

    these are the outputs to fill the statement.

  • handler

    the handler which is called once the operation completes. It will return a ResultSet.

closeshared default void close()

Close the client

closeshared default void close(Anything(Throwable?) handler)

Close the client and release all resources. Call the handler when close is complete.

Parameters:
  • handler

    the handler that will be called when close is complete

getConnectionshared default SQLClient getConnection(Anything(Throwable|SQLConnection) handler)

Returns a connection that can be used to perform SQL operations on. It's important to remember to close the connection when you are done, so it is returned to the pool.

Parameters:
  • handler

    the handler which is called when the JdbcConnection object is ready for use.

queryshared actual default SQLClient query(String sql, Anything(Throwable|ResultSet) handler)

Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL statement and returns it back after the execution.

Parameters:
  • sql

    the statement to execute

  • handler

    the result handler

querySingleshared actual default SQLOperations querySingle(String sql, Anything(Throwable|Array?) handler)

Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

Parameters:
  • sql

    the statement to execute

  • handler

    the result handler

querySingleWithParamsshared actual default SQLOperations querySingleWithParams(String sql, Array arguments, Anything(Throwable|Array?) handler)

Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

Parameters:
  • sql

    the statement to execute

  • arguments

    the arguments

  • handler

    the result handler

queryWithParamsshared actual default SQLClient queryWithParams(String sql, Array arguments, Anything(Throwable|ResultSet) handler)

Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL prepared statement and returns it back after the execution.

Parameters:
  • sql

    the statement to execute

  • arguments

    the arguments to the statement

  • handler

    the result handler

updateshared actual default SQLClient update(String sql, Anything(Throwable|UpdateResult) handler)

Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

Parameters:
  • sql

    the SQL to execute. For example INSERT INTO table …

  • handler

    the handler which is called once the operation completes.

updateWithParamsshared actual default SQLClient updateWithParams(String sql, Array params, Anything(Throwable|UpdateResult) handler)

Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters

Parameters:
  • sql

    the SQL to execute. For example INSERT INTO table …

  • params

    these are the parameters to fill the statement.

  • handler

    the handler which is called once the operation completes.

Inherited Methods
Methods inherited from: Object
equals
Methods inherited from: SQLOperations