Ballerina API Documentation

Enums of ballerina.data.sql package

public enum DB

The Databases which has direct parameter support.

Enumerators:

Name Description
MYSQL MySQL DB with connection url in the format of jdbc:mysql://[HOST]:[PORT]/[database]
SQLSERVER SQL Server DB with connection url in the format of jdbc:sqlserver://[HOST]:[PORT];databaseName=[database]
ORACLE Oracle DB with connection url in the format of jdbc:oracle:thin:[username/password]@[HOST]:[PORT]/[database]
SYBASE Sybase DB with connection url in the format of jdbc:sybase:Tds:[HOST]:[PORT]/[database]
POSTGRES PostgreSQL DB with connection url in the format of jdbc:postgresql://[HOST]:[PORT]/[database]
IBMDB2 IBMDB2 DB with connection url in the format of jdbc:db2://[HOST]:[PORT]/[database]
HSQLDB_SERVER HSQL Server with connection url in the format of jdbc:hsqldb:hsql://[HOST]:[PORT]/[database]
HSQLDB_FILE HSQL Server with connection url in the format of jdbc:hsqldb:file:[path]/[database]
H2_SERVER H2 Server DB with connection url in the format of jdbc:h2:tcp://[HOST]:[PORT]/[database]
H2_FILE H2 File DB with connection url in the format of jdbc:h2:file://[path]/[database]
DERBY_SERVER DERBY server DB with connection url in the format of jdbc:derby://[HOST]:[PORT]/[database]
DERBY_FILE Derby file DB with connection url in the format of jdbc:derby://[path]/[database]
GENERIC Custom DB connection with given connection url

public enum Direction

The direction of the parameter

Enumerators:

Name Description
IN IN parameters are used to send values to stored procedures
OUT OUT parameters are used to get values from stored procedures
INOUT INOUT parameters are used to send values and get values from stored procedures

public enum Type

The SQL Datatype of the parameter

Enumerators:

Name Description
VARCHAR Small, variable-length character string
CHAR Small, fixed-length character string
LONGVARCHAR Large, variable-length character string
NCHAR Small, fixed-length character string with unicode support
LONGNVARCHAR Large, variable-length character string with unicode support
NVARCHAR VARCHAR: Small, variable-length character string
BIT Single bit value that can be zero or one, or null
BOOLEAN Boolean value either True or false
TINYINT 8-bit integer value which may be unsigned or signed
SMALLINT 16-bit signed integer value which may be unsigned or signed
INTEGER 32-bit signed integer value which may be unsigned or signed
BIGINT 64-bit signed integer value which may be unsigned or signed
NUMERIC Fixed-precision and scaled decimal values
DECIMAL Fixed-precision and scaled decimal values
REAL Single precision floating point number
FLOAT Double precision floating point number
DOUBLE Double precision floating point number
BINARY Small, fixed-length binary value
BLOB Binary Large Object
LONGVARBINARY Large, variable-length binary value
VARBINARY Small, variable-length binary value
CLOB Character Large Object
NCLOB Character large objects in multibyte national character set
DATE Date consisting of day, month, and year
TIME Time consisting of hours, minutes, and seconds
DATETIME Both DATE and TIME with additional a nanosecond field
TIMESTAMP Both DATE and TIME with additional a nanosecond field
ARRAY Composite data value that consists of zero or more elements of a specified data type
STRUCT User defined structured type, consists of one or more attributes


Connectors of ballerina.data.sql package

public connector ClientConnector (DB dbType, string hostOrPath, int port, string dbName, string username, string password, ConnectionProperties options)

The Client Connector for SQL databases.

Parameters:

Parameter NameData TypeDescription
dbTypeDBSQL database type
hostOrPathstringHost name of the database or file path for file based database
portintPort of the database
dbNamestringName of the database to connect
usernamestringUsername for the database connection
passwordstringPassword for the database connection
optionsConnectionPropertiesConnectionProperties for the connection pool configuration

Actions:

action batchUpdate(string query, Parameter[][] parameters)

The batchUpdate action implementation for SQL connector to batch data insert.

Parameters:

Parameter NameData TypeDescription
querystringSQL query to execute
parametersParameter[][]Parameter array used with the SQL query

Return Parameters:

Return VariableData TypeDescription
int[]Array of update counts

action call(string query, Parameter[] parameters, type structType)

The call action implementation for SQL connector to invoke stored procedures/functions.

Parameters:

Parameter NameData TypeDescription
querystringSQL query to execute
parametersParameter[]Parameter array used with the SQL query
structTypetypequery: SQL query to execute

Return Parameters:

Return VariableData TypeDescription
datatableResult 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, type structType)

The select action implementation for SQL connector to select data from tables.

Parameters:

Parameter NameData TypeDescription
querystringSQL query to execute
parametersParameter[]Parameter array used with the SQL query
structTypetypequery: SQL query to execute

Return Parameters:

Return VariableData TypeDescription
datatableResult 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 NameData TypeDescription
querystringSQL query to execute
parametersParameter[]Parameter array used with the SQL query

Return Parameters:

Return VariableData TypeDescription
intUpdated 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 NameData TypeDescription
querystringSQL query to execute
parametersParameter[]Parameter array used with the SQL query
keyColumnsstring[]Names of auto generated columns for which the auto generated key values are returned

Return Parameters:

Return VariableData TypeDescription
intUpdated row count during the query exectuion
string[]Array of auto generated key values during the query execution


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
urlstringPlatform independent DB access URL
dataSourceClassNamestringName of the DataSource class provided by the JDBC driver
connectionTestQuerystringQuery that will be executed to validate that the connection to the database is still alive
poolNamestringUser-defined name for the connection pool and appears mainly in logging
catalogstringCatalog of connections created by this pool
connectionInitSqlstringSQL statement that will be executed after every new connection creation before adding it to the pool
driverClassNamestringFully qualified Java class name of the JDBC driver to be used
transactionIsolationstringTransaction isolation level of connections returned from the pool. The supported values are TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ and TRANSACTION_SERIALIZABLE
autoCommitbooleanAuto-commit behavior of connections returned from the pool
isolateInternalQueriesbooleanDetermines whether HikariCP isolates internal pool queries, such as the connection alive test, in their own transaction
allowPoolSuspensionbooleanWhether the pool can be suspended and resumed through JMX
readOnlybooleanWhether Connections obtained from the pool are in read-only mode by default
isXAbooleanWhether Connections are used for a distributed transaction
maximumPoolSizeintMaximum size that the pool is allowed to reach, including both idle and in-use connections
connectionTimeoutintMaximum number of milliseconds that a client will wait for a connection from the pool
idleTimeoutintMaximum amount of time that a connection is allowed to sit idle in the pool
minimumIdleintMinimum number of idle connections that pool tries to maintain in the pool
maxLifetimeintMaximum lifetime of a connection in the pool
validationTimeoutintMaximum amount of time that a connection will be tested for aliveness
leakDetectionThresholdintAmount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak
datasourcePropertiesmapData 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
sqlTypeTypeThe data type of the corresponding SQL parameter
valueanyValue of paramter pass into the SQL query
directionDirectionDirection of the SQL Parameter IN, OUT, or INOUT


Menu

  • Enums
    • DB
    • Direction
    • Type
  • Connectors
    • ClientConnector (DB dbType, string hostOrPath, int port, string dbName, string username, string password, ConnectionProperties options)
      • batchUpdate(string query, Parameter[][] parameters)
      • call(string query, Parameter[] parameters, type structType)
      • close()
      • select(string query, Parameter[] parameters, type structType)
      • update(string query, Parameter[] parameters)
      • updateWithGeneratedKeys(string query, Parameter[] parameters, string[] keyColumns)
  • Structs
    • ConnectionProperties
    • Parameter

Copyright 2017 Ballerina API Documentation