std.database.sql
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 (deprecated) | Specifies the parent class of all SQL data types. |
| SqlNullableDbType (deprecated) | 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 (deprecated) | Specifies a large integer corresponding to the Cangjie Int64 type. |
| SqlBinary (deprecated) | Specifies a fixed-length binary string corresponding to the Cangjie Array<Byte> type. |
| SqlBlob (deprecated) | Specifies an excessively large variable-length binary string (BINARY LARGE OBJECT) corresponding to the Cangjie InputStream type. |
| SqlBool (deprecated) | Specifies the Boolean type corresponding to the Cangjie Bool type. |
| SqlByte (deprecated) | Specifies a byte corresponding to the Cangjie Int8 type. |
| SqlChar (deprecated) | Specifies a fixed-length string corresponding to the Cangjie String type. |
| SqlClob (deprecated) | Specifies an excessively large variable-length string (RUNE LARGE OBJECT) corresponding to the Cangjie InputStream type. |
| SqlDate (deprecated) | Specifies a date, which must be in the format of dd-mm-yyyy and corresponds to the Cangjie DateTime type. |
| SqlDecimal (deprecated) | Specifies a high-precision number corresponding to the Cangjie Decimal type. |
| SqlDouble (deprecated) | Specifies a double-precision floating-point number corresponding to the Cangjie Float64 type. |
| SqlInteger (deprecated) | Specifies a medium integer corresponding to the Cangjie Int32 type. |
| SqlInterval (deprecated) | Specifies the time interval corresponding to the Cangjie Duration type. |
| SqlReal (deprecated) | Specifies a floating-point number corresponding to the Cangjie Float32 type. |
| SqlSmallInt (deprecated) | Specifies a small integer corresponding to the Cangjie Int16 type. |
| SqlTime (deprecated) | Specifies the time, which must be in the format of hhmmss.ms and corresponds to the Cangjie DateTime type. |
| SqlTimestamp (deprecated) | Specifies a timestamp corresponding to the Cangjie DateTime type. |
| SqlTimeTz (deprecated) | Specifies the time with a time zone, which must be in the format of hhmmss.ms and corresponds to the Cangjie DateTime type. |
| SqlVarBinary (deprecated) | Specifies a variable-length binary string corresponding to the Cangjie Array<Byte> type. |
| SqlVarchar (deprecated) | Specifies a variable-length string corresponding to the Cangjie String type. |
| SqlNullableBigInt (deprecated) | Specifies a large integer corresponding to the Cangjie Int64 type, which can be a Null value in the database. |
| SqlNullableBinary (deprecated) | Specifies a fixed-length binary string corresponding to the Cangjie Array<Byte> type, which can be a Null value in the database. |
| SqlNullableBlob (deprecated) | 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 (deprecated) | Specifies the Boolean type corresponding to the Cangjie Bool type, which can be a Null value in the database. |
| SqlNullableByte (deprecated) | Specifies a byte corresponding to the Cangjie Int8 type, which can be a Null value in the database. |
| SqlNullableChar (deprecated) | Specifies a fixed-length binary string corresponding to the Cangjie String type, which can be a Null value in the database. |
| SqlNullableClob (deprecated) | 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 (deprecated) | 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 (deprecated) | Specifies a high-precision number corresponding to the Cangjie Decimal type, which can be a Null value in the database. |
| SqlNullableDouble (deprecated) | Specifies a double-precision float-point number corresponding to the Cangjie Float64 type, which can be a Null value in the database. |
| SqlNullableInteger (deprecated) | Specifies a medium integer corresponding to the Cangjie Int32 type, which can be a Null value in the database. |
| SqlNullableInterval (deprecated) | Specifies the time interval corresponding to the Cangjie Duration type, which can be a Null value in the database. |
| SqlNullableReal (deprecated) | Specifies a floating-point number corresponding to the Cangjie Float32 type, which can be a Null value in the database. |
| SqlNullableSmallInt (deprecated) | Specifies a small integer corresponding to the Cangjie Int16 type, which can be a Null value in the database. |
| SqlNullableTime (deprecated) | 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 (deprecated) | Specifies a timestamp corresponding to the Cangjie DateTime type, which can be a Null value in the database. |
| SqlNullableTimeTz (deprecated) | 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 (deprecated) | Specifies a variable-length binary string corresponding to the Cangjie Array<Byte> type, which can be a Null value in the database. |
| SqlNullableVarchar (deprecated) | 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. |