Class: SQLClient

vertx-sql-js/sql_client~ SQLClient

new SQLClient()

A common asynchronous client interface for interacting with SQL compliant database
Source:

Methods

call(sql, handler) → {SQLClient}

Calls the given SQL PROCEDURE which returns the result from the procedure.
Parameters:
Name Type Description
sql string the SQL to execute. For example {call getEmpName}.
handler function the handler which is called once the operation completes. It will return a ResultSet.
Source:
Returns:
Type
SQLClient

callWithParams(sql, params, outputs, handler) → {SQLClient}

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:
Name Type Description
sql string the SQL to execute. For example {call getEmpName (?, ?)}.
params Array these are the parameters to fill the statement.
outputs Array these are the outputs to fill the statement.
handler function the handler which is called once the operation completes. It will return a ResultSet.
Source:
Returns:
Type
SQLClient

close()

Close the client
Source:

getConnection(handler) → {SQLClient}

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:
Name Type Description
handler function the handler which is called when the JdbcConnection object is ready for use.
Source:
Returns:
Type
SQLClient

query(sql, handler) → {SQLClient}

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:
Name Type Description
sql string the statement to execute
handler function the result handler
Source:
Returns:
self
Type
SQLClient

querySingle(sql, handler) → {SQLOperations}

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:
Name Type Description
sql string the statement to execute
handler function the result handler
Source:
Returns:
self
Type
SQLOperations

querySingleWithParams(sql, arguments, handler) → {SQLOperations}

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:
Name Type Description
sql string the statement to execute
arguments Array the arguments
handler function the result handler
Source:
Returns:
self
Type
SQLOperations

queryStream(sql, handler) → {SQLClient}

Executes the given SQL SELECT statement which returns the results of the query as a read stream.
Parameters:
Name Type Description
sql string the SQL to execute. For example SELECT * FROM table ....
handler function the handler which is called once the operation completes. It will return a SQLRowStream.
Source:
Returns:
Type
SQLClient

queryStreamWithParams(sql, params, handler) → {SQLClient}

Executes the given SQL SELECT statement which returns the results of the query as a read stream.
Parameters:
Name Type Description
sql string the SQL to execute. For example SELECT * FROM table ....
params Array these are the parameters to fill the statement.
handler function the handler which is called once the operation completes. It will return a SQLRowStream.
Source:
Returns:
Type
SQLClient

queryWithParams(sql, arguments, handler) → {SQLClient}

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:
Name Type Description
sql string the statement to execute
arguments Array the arguments to the statement
handler function the result handler
Source:
Returns:
self
Type
SQLClient

update(sql, handler) → {SQLClient}

Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.
Parameters:
Name Type Description
sql string the SQL to execute. For example INSERT INTO table ...
handler function the handler which is called once the operation completes.
Source:
Returns:
Type
SQLClient

updateWithParams(sql, params, handler) → {SQLClient}

Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters
Parameters:
Name Type Description
sql string the SQL to execute. For example INSERT INTO table ...
params Array these are the parameters to fill the statement.
handler function the handler which is called once the operation completes.
Source:
Returns:
Type
SQLClient