This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Clients - java.jdbc : Client

Represents a JDBC client endpoint.

Constructor

__init

(ClientConfiguration c)

Remote Methods

call

The call remote function implementation for JDBC Client to invoke stored procedures/functions.

select

The select remote function implementation for JDBC Client to select data from tables.

update

The update remote function implementation for JDBC Client to insert/delete/modify data and schema of the database.

batchUpdate

The batchUpdate remote function implementation for JDBC Client to execute batch operations.

Methods

Stops the JDBC client.

call

(string sqlQuery, typedesc[]? recordType, Param... parameters)

returns table[] | () | Error

The call remote function implementation for JDBC Client to invoke stored procedures/functions.

Parameters

  • sqlQuery string
  • The SQL stored procedure to execute

  • recordType typedesc[]?
  • Array of record types of the returned tables if there is any

  • parameters Param...
  • The parameters to be passed to the procedure/function call

  • Return Type

    (table[] | () | Error)
  • A table[] if there are tables returned by the call remote function and else nil. Error will be returned if there is any error

select

(string sqlQuery, typedesc? recordType, Param... parameters)

returns table | Error

The select remote function implementation for JDBC Client to select data from tables.

Parameters

  • sqlQuery string
  • SQL query to execute

  • recordType typedesc?
  • Type of the returned table

  • parameters Param...
  • The parameters to be passed to the select query

  • Return Type

    (table | Error)
  • A table returned by the SQL query statement or else Error will be returned if there is an error

update

(string sqlQuery, Param... parameters)

returns UpdateResult | Error

The update remote function implementation for JDBC Client to insert/delete/modify data and schema of the database.

Parameters

  • sqlQuery string
  • SQL statement to execute

  • parameters Param...
  • The parameters to be passed to the update query

  • Return Type

    (UpdateResult | Error)
  • UpdateResult with the updated row count and key column values, else Error will be returned if there is an error

batchUpdate

(string sqlQuery, boolean rollbackAllInFailure, Param?[]... parameters)

returns BatchUpdateResult

The batchUpdate remote function implementation for JDBC Client to execute batch operations.

Parameters

  • sqlQuery string
  • SQL statement to execute

  • rollbackAllInFailure boolean
  • If one of the commands in a batch update fails to execute properly, the JDBC driver may or may not continue to process the remaining commands in the batch. This property can be used to override this behavior. When it is set to true, if there is a failure in a few commands and the JDBC driver continues with the remaining commands, the successfully executed commands in the batch also will get rolled back.

  • parameters Param?[]...
  • Variable number of parameter arrays each representing the set of parameters belonging to each update statement

  • Return Type

    (BatchUpdateResult)
  • A BatchUpdateResult with the updated row count and returned error if any. If all the commands in the batch have executed successfully, the error will be nil. If one or more commands have failed, the returnedError field will give the corresponding Error along with the int[] which contains updated row count or the status returned from each command in the batch.

stop

()

returns error?

Stops the JDBC client.

  • Return Type

    (error?)
  • Possible error during closing the client