Global variables of ballerina.data.sql package
Variable Name | Data Type | Description |
---|---|---|
MYSQL | string | Construct MySQL DB jdbc url in the format of jdbc:mysql://[HOST]:[PORT]/[database] |
SQLSERVER | string | Construct SQL Server DB jdbc url in the format of jdbc:sqlserver://[HOST]:[PORT];databaseName=[database] |
ORACLE | string | Construct Oracle DB jdbc url in the format of jdbc:oracle:thin:[username/password]@[HOST]:[PORT]/[database] |
SYBASE | string | Construct Sybase DB jdbc url in the format of jdbc:sybase:Tds:[HOST]:[PORT]/[database] |
POSTGRE | string | Construct PostgreSQL DB jdbc url in the format of jdbc:postgresql://[HOST]:[PORT]/[database] |
IBMDB2 | string | Construct IBM Db2 DB jdbc url in the format of jdbc:db2://[HOST]:[PORT]/[database] |
HSQLDB_SERVER | string | Construct HSQLDB SERVER dB jdbc url in the format of jdbc:hsqldb:hsql://[HOST]:[PORT]/[database] |
HSQLDB_FILE | string | Construct HSQLDB FILE DB jdbc url in the format of jdbc:hsqldb:file:[path]/[database] |
H2_SERVER | string | Construct H2 SERVER DB jdbc url in the format of jdbc:h2:tcp://[HOST]:[PORT]/[database] |
H2_FILE | string | Construct H2 FILE DB jdbc url in the format of jdbc:h2:file://[path]/[database] |
DERBY_SERVER | string | Construct Derby SERVER DB jdbc url in the format of jdbc:derby://[HOST]:[PORT]/[database] |
DERBY_FILE | string | Construct Derby FILE DB jdbc url in the format of jdbc:derby://[path]/[database] |
Connectors of ballerina.data.sql package
public connector ClientConnector (string dbType, string hostOrPath, int port, string dbName, string username, string password, ConnectionProperties options)
The Client Connector for SQL databases.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
dbType | string | SQL database type |
hostOrPath | string | Host name of the database or file path for file based database |
port | int | Port of the database |
dbName | string | Name of the database to connect |
username | string | Username for the database connection |
password | string | Password for the database connection |
options | ConnectionProperties | ConnectionProperties for the connection pool configuration |
action batchUpdate(string query, Parameter[][] parameters)
The batchUpdate action implementation for SQL connector to batch data insert.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
query | string | SQL query to execute |
parameters | Parameter[][] | Parameter array used with the SQL query |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int[] | int[]: Array of update counts |
action call(string query, Parameter[] parameters)
The call action implementation for SQL connector to invoke stored procedures/functions.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
query | string | SQL query to execute |
parameters | Parameter[] | Parameter array used with the SQL query |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
datatable | datatable: Result set for the given query |
action close()
The close action implementation for SQL connector to shutdown the connection pool.
action select(string query, Parameter[] parameters)
The select action implementation for SQL connector to select data from tables.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
query | string | SQL query to execute |
parameters | Parameter[] | Parameter array used with the SQL query |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
datatable | datatable: Result set for the given query |
action update(string query, Parameter[] parameters)
The update action implementation for SQL connector to update data and schema of the database.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
query | string | SQL query to execute |
parameters | Parameter[] | Parameter array used with the SQL query |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | int: Updated row count |
action updateWithGeneratedKeys(string query, Parameter[] parameters, string[] keyColumns)
The updateWithGeneratedKeys action implementation for SQL connector which returns the auto generated keys during the update action.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
query | string | SQL query to execute |
parameters | Parameter[] | Parameter array used with the SQL query |
keyColumns | string[] | Names of auto generated columns for which the auto generated key values are returned |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | int: Updated row count during the query exectuion | |
string[] | int: Updated row count during the query exectuion |
Structs of ballerina.data.sql package
public struct ConnectionProperties
ConnectionProperties structs represents the properties which are used to configure DB connection pool
Fields:
Field Name | Data Type | Description |
---|---|---|
url | string | Platform independent DB access URL |
dataSourceClassName | string | Name of the DataSource class provided by the JDBC driver |
connectionTestQuery | string | Query that will be executed to validate that the connection to the database is still alive |
poolName | string | User-defined name for the connection pool and appears mainly in logging |
catalog | string | Catalog of connections created by this pool |
connectionInitSql | string | SQL statement that will be executed after every new connection creation before adding it to the pool |
driverClassName | string | Fully qualified Java class name of the JDBC driver to be used |
transactionIsolation | string | Transaction isolation level of connections returned from the pool. The supported values are TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ and TRANSACTION_SERIALIZABLE |
autoCommit | boolean | Auto-commit behavior of connections returned from the pool |
isolateInternalQueries | boolean | Determines whether HikariCP isolates internal pool queries, such as the connection alive test, in their own transaction |
allowPoolSuspension | boolean | Whether the pool can be suspended and resumed through JMX |
readOnly | boolean | Whether Connections obtained from the pool are in read-only mode by default |
isXA | boolean | Whether Connections are used for a distributed transaction |
maximumPoolSize | int | Maximum size that the pool is allowed to reach, including both idle and in-use connections |
connectionTimeout | int | Maximum number of milliseconds that a client will wait for a connection from the pool |
idleTimeout | int | Maximum amount of time that a connection is allowed to sit idle in the pool |
minimumIdle | int | Minimum number of idle connections that pool tries to maintain in the pool |
maxLifetime | int | Maximum lifetime of a connection in the pool |
validationTimeout | int | Maximum amount of time that a connection will be tested for aliveness |
leakDetectionThreshold | int | Amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak |
datasourceProperties | map | Data source specific properties which are used along with the dataSourceClassName |
public struct Parameter
Parameter struct represents a query parameter for the SQL queries specified in connector actions
Fields:
Field Name | Data Type | Description |
---|---|---|
sqlType | string | The data type of the corresponding SQL parameter |
value | any | Value of paramter pass into the SQL query |
direction | int | Direction of the SQL Parameter 0 - IN, 1- OUT, 2 - INOUT |