Client: Client

Isolated

Represents a JDBC client.

Constructor

Initializes the JDBC client.

init (string url, string? user, string? password, Options? options, ConnectionPool? connectionPool)
  • url string
  • The JDBC URL to be used for the database connection

  • user string? ()
  • If the database is secured, the username

  • password string? ()
  • The password of the database associated with the provided username

  • options Options? ()
  • The JDBC client properties

  • connectionPool ConnectionPool? ()
  • The sql:ConnectionPool to be used for the connection. If there is no connectionPool provided, the global connection pool (shared by all clients) will be used

Remote Methods

query

Executes the query, which may return multiple results.

queryRow

Executes the query, which is expected to return at most one row of the result.

execute

Executes the SQL query.

batchExecute

Executes the SQL query with multiple sets of parameters in a batch.

call

Executes a SQL query, which calls a stored procedure.

Methods

close

Closes the SQL client and shuts down the connection pool.

query

function query(ParameterizedQuery sqlQuery, typedesc<record {}> rowType) returns stream<rowType, Error?>
Isolated Function
Remote Function

Executes the query, which may return multiple results.

Parameters

  • sqlQuery ParameterizedQuery
  • The SQL query such as `SELECT * from Album WHERE name=${albumName}`

  • rowType typedesc<record {}> (default <>)
  • The typedesc of the record to which the result needs to be returned

Return Type

(stream<rowType, Error?>)

Stream of records in the rowType type

queryRow

function queryRow(ParameterizedQuery sqlQuery, typedesc<anydata> returnType) returns returnType | Error
Isolated Function
Remote Function

Executes the query, which is expected to return at most one row of the result. If the query does not return any results, an sql:NoRowsError is returned.

Parameters

  • sqlQuery ParameterizedQuery
  • The SQL query such as `SELECT * from Album WHERE name=${albumName}`

  • returnType typedesc<anydata> (default <>)
  • The typedesc of the record to which the result needs to be returned. It can be a basic type if the query result contains only one column

Return Type

(returnType | Error)

Result in the returnType type or an sql:Error

execute

function execute(ParameterizedQuery sqlQuery) returns ExecutionResult | Error
Isolated Function
Remote Function

Executes the SQL query. Only the metadata of the execution is returned (not the results from the query).

Parameters

  • sqlQuery ParameterizedQuery
  • The SQL query such as `DELETE FROM Album WHERE artist=${artistName}`

Return Type

(ExecutionResult | Error)

Metadata of the query execution as an sql:ExecutionResult or an sql:Error

batchExecute

function batchExecute(ParameterizedQuery[ ] sqlQueries) returns ExecutionResult[ ] | Error
Isolated Function
Remote Function

Executes the SQL query with multiple sets of parameters in a batch. Only the metadata of the execution is returned (not results from the query). If one of the commands in the batch fails, this will return an sql:BatchExecuteError. However, the driver may or may not continue to process the remaining commands in the batch after a failure.

Parameters

Return Type

(ExecutionResult[ ] | Error)

Metadata of the query execution as an sql:ExecutionResult[] or an sql:Error

call

function call(ParameterizedCallQuery sqlQuery, typedesc<record {}>[ ] rowTypes) returns ProcedureCallResult | Error
Isolated Function
Remote Function

Executes a SQL query, which calls a stored procedure. This may or may not return results.

Parameters

  • rowTypes typedesc<record {}>[ ] (default [])
  • typedesc array of the records to which the results need to be returned

Return Type

(ProcedureCallResult | Error)

Summary of the execution and results are returned in an sql:ProcedureCallResult, or an sql:Error

close

function close() returns Error?
Isolated Function

Closes the SQL client and shuts down the connection pool.

Return Type

(Error?)

Possible error when closing the client