std.database.sql Package
Function Description
The database.sql package provides the interface for accessing the database.
This package provides universal SQL/CLI interfaces and works with the database driver to perform operations on the database.
Notes:
Currently, only SQL/CLI interfaces are supported.
The following table lists the mapping between SQL data types and Cangjie data types.
| SQL | CDBC/Cangjie | SqlDataType | Description |
|---|---|---|---|
RUNE | String | SqlChar | - |
VARCHAR | String | SqlVarchar | - |
CLOB | io.InputStream | SqlClob | - |
BINARY | Array<Byte> | SqlBinary | - |
VARBINARY | Array<Byte> | SqlVarBinary | - |
BLOB | io.InputStream | SqlBlob | - |
NUMERIC | Decimal | sqlDecimal | - |
DECIMAL | Decimal | sqlDecimal | - |
BOOLEAN | Bool | SqlBool | - |
TINYINT | Int8 | SqlByte | - |
SMALLINT | Int16 | SqlSmallInt | - |
INTEGER | Int32 | SqlInteger | - |
BIGINT | Int64 | SqlBigInt | - |
REAL | Float32 | SqlReal | - |
DOUBLE | Float64 | SqlDouble | - |
DATE | time.DateTime | SqlDate | The value can be YEAR, MONTH, or DAY. |
TIME | time.DateTime | SqlTime | The value can be HOUR, MINUTE, or SECOND but cannot be TIME ZONE. |
TIMETZ | time.DateTime | SqlTimeTz | The value can be HOUR, MINUTE, SECOND, or TIME ZONE. |
TIMESTAMP | time.DateTime | SqlTimestamp | The value can be YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or TIME ZONE. |
INTERVAL | time.Duration | SqlInterval | Interval in year-month format or day-time format. |
API List
Interface
| Name | Description |
|---|---|
| ColumnInfo | Specifies the column information of the result returned by executing the Select/Query statement. |
| Connection | Specifies the database connection interface. |
| Datasource | Specifies the data source interface. |
| Driver | Specifies the database driver interface. |
| QueryResult | Specifies the interface used to query the result generated by executing the Select statement. |
| SqlDbType | Specifies the parent class of all SQL data types. |
| SqlNullableDbType | Specifies the parent class of the SQL data type that allows null values. |
| Statement | Specifies the interface of SQL statement pre-execution. |
| Transaction | Defines the core behavior of database transactions. |
| UpdateResult | Specifies the interface used to update the result generated by executing the Insert, Update, and Delete statements. |
Class
| Name | Description |
|---|---|
| DriverManager | Obtains the database driver instance according to the driver name during running. |
| PooledDatasource | Specifies a database connection pool class, which provides the database connection pool capability. |
| SqlOption | Specifies the predefined SQL option name and value. |
| SqlBigInt | Specifies a large integer corresponding to the Cangjie Int64 type. |
| SqlBinary | Specifies a fixed-length binary string corresponding to the Cangjie Array<Byte> type. |
| SqlBlob | Specifies an excessively large variable-length binary string (BINARY LARGE OBJECT) corresponding to the Cangjie InputStream type. |
| SqlBool | Specifies the Boolean type corresponding to the Cangjie Bool type. |
| SqlByte | Specifies a byte corresponding to the Cangjie Int8 type. |
| SqlChar | Specifies a fixed-length string corresponding to the Cangjie String type. |
| SqlClob | Specifies an excessively large variable-length string (RUNE LARGE OBJECT) corresponding to the Cangjie InputStream type. |
| SqlDate | Specifies a date, which must be in the format of dd-mm-yyyy and corresponds to the Cangjie DateTime type. |
| SqlDecimal | Specifies a high-precision number corresponding to the Cangjie Decimal type. |
| SqlDouble | Specifies a double-precision floating-point number corresponding to the Cangjie Float64 type. |
| SqlInteger | Specifies a medium integer corresponding to the Cangjie Int32 type. |
| SqlInterval | Specifies the time interval corresponding to the Cangjie Duration type. |
| SqlReal | Specifies a floating-point number corresponding to the Cangjie Float32 type. |
| SqlSmallInt | Specifies a small integer corresponding to the Cangjie Int16 type. |
| SqlTime | Specifies the time, which must be in the format of hhmmss.ms and corresponds to the Cangjie DateTime type. |
| SqlTimestamp | Specifies a timestamp corresponding to the Cangjie DateTime type. |
| SqlTimeTz | Specifies the time with a time zone, which must be in the format of hhmmss.ms and corresponds to the Cangjie DateTime type. |
| SqlVarBinary | Specifies a variable-length binary string corresponding to the Cangjie Array<Byte> type. |
| SqlVarchar | Specifies a variable-length string corresponding to the Cangjie String type. |
| SqlNullableBigInt | Specifies a large integer corresponding to the Cangjie Int64 type, which can be a Null value in the database. |
| SqlNullableBinary | Specifies a fixed-length binary string corresponding to the Cangjie Array<Byte> type, which can be a Null value in the database. |
| SqlNullableBlob | Specifies an excessively large variable-length binary string (BINARY LARGE OBJECT) corresponding to the Cangjie InputStream type, which can be a Null value in the database. |
| SqlNullableBool | Specifies the Boolean type corresponding to the Cangjie Bool type, which can be a Null value in the database. |
| SqlNullableByte | Specifies a byte corresponding to the Cangjie Int8 type, which can be a Null value in the database. |
| SqlNullableChar | Specifies a fixed-length binary string corresponding to the Cangjie String type, which can be a Null value in the database. |
| SqlNullableClob | Specifies an excessively large variable-length string (RUNE LARGE OBJECT) corresponding to the Cangjie InputStream type, which can be a Null value in the database. |
| SqlNullableDate | Specifies a date, which must be in the format of dd-mm-yyyy and corresponds to the Cangjie DateTime type. It can be a Null value in the database. |
| SqlNullableDecimal | Specifies a high-precision number corresponding to the Cangjie Decimal type, which can be a Null value in the database. |
| SqlNullableDouble | Specifies a double-precision float-point number corresponding to the Cangjie Float64 type, which can be a Null value in the database. |
| SqlNullableInteger | Specifies a medium integer corresponding to the Cangjie Int32 type, which can be a Null value in the database. |
| SqlNullableInterval | Specifies the time interval corresponding to the Cangjie Duration type, which can be a Null value in the database. |
| SqlNullableReal | Specifies a floating-point number corresponding to the Cangjie Float32 type, which can be a Null value in the database. |
| SqlNullableSmallInt | Specifies a small integer corresponding to the Cangjie Int16 type, which can be a Null value in the database. |
| SqlNullableTime | Specifies the time, which must be in the format of hhmmss.ms and corresponds to the Cangjie DateTime type. It can be a Null value in the database. |
| SqlNullableTimestamp | Specifies a timestamp corresponding to the Cangjie DateTime type, which can be a Null value in the database. |
| SqlNullableTimeTz | Specifies the time with a time zone, which must be in the format of hhmmss.ms and corresponds to the Cangjie DateTime type. It can be a Null value in the database. |
| SqlNullableVarBinary | Specifies a variable-length binary string corresponding to the Cangjie Array<Byte> type, which can be a Null value in the database. |
| SqlNullableVarchar | Specifies a variable-length string corresponding to the Cangjie String type, which can be a Null value in the database. |
Enumeration
| Name | Description |
|---|---|
| ConnectionState | Describes the current status of the connection to the data source. |
| TransactionAccessMode | Specifies the transaction read/write mode. |
| TransactionDeferrableMode | Specifies the transaction delay mode. |
| TransactionIsoLevel | Defines when and how the result of an operation in a transaction is visible to other concurrent transaction operations in the database system. |
Exception Class
| Name | Description |
|---|---|
| SqlException | Handles SQL-related exceptions. |