During the providing phase, data is converted from JDBC data types to Variant data types. This involves the following:
When you obtain data from the data source, the JBDC data types are translated into corresponding Variant data types. The JDBC data types are listed below and are defined in java.sql.Types. The Variant data types are defined in com.borland.dx.dataset.Variant.
Precision, scale and type have default values if they are not explicitly set. Precision and scale default to -1. Type defaults to Variant.STRING. The sqlType is based on the value returned from the JDBC driver.
For information on data mapping of SQL server physical types to JBDC data types, check your driver documentation.
JDBC type | Maps to Variant data type |
---|---|
java.sql.Types.BIGINT | Variant.LONG |
java.sql.Types.BINARY | Variant.BINARY with precision |
java.sql.Types.BIT | Variant.BOOLEAN |
java.sql.Types.CHAR | Variant.STRING with precision |
java.sql.Types.DATE | Variant.DATE |
java.sql.Types.DECIMAL | Variant.BIGDECIMAL with scale and precision |
java.sql.Types.DOUBLE | Variant.DOUBLE |
java.sql.Types.FLOAT | Variant.DOUBLE |
java.sql.Types.INTEGER | Variant.INT |
java.sql.Types.LONGVARBINARY | Variant.BINARY without precision |
java.sql.Types.LONGVARCHAR | Variant.STRING without precision (BLOB columns typically have an open-ended length) |
java.sql.Types.NUMERIC | Variant.BIGDECIMAL with scale and precision |
java.sql.Types.OTHER | Variant.OBJECT |
java.sql.Types.REAL | Variant.DOUBLE |
java.sql.Types.SMALLINT | Variant.SHORT |
java.sql.Types.TIME | Variant.TIME |
java.sql.Types.TIMESTAMP | Variant.TIMESTAMP |
java.sql.Types.TINYINT | Variant.BYTE |
java.sql.Types.VARBINARY | Variant.BINARY without precision |
java.sql.Types.VARCHAR | Variant.STRING with precision |
In addition to the initial JDBC to Variant data type conversion, a second data type translation phase occurs where the Variant-typed data is stored in Column components.
If you set a column's dataType property, thereby over-riding the default JDBC-to-Variant mapping, automatic data type coercion is done, for example, in the case of persistent columns. The exception to the automatic type coercion is when converting to and from a String to any type other than String(and other conversions involving such differing data types). A VariantException is thrown in these cases.
To customize the coercion, or to prevent the VariantException from being thrown, wire the CoerceToListener.coerceToColumn() event.
When you write an event handler for CoerceToListener, you typically need to write one for CoerceFromListener as well. If your DataSet is editable and uses the default UpdateMode option, JDataStore will generate update queries that look for rows on the server that match the original data of the rows that were edited. Without coercion to convert field values back to what they looked like before the CoerceToListener modified them, these update queries will likely fail. Note that this will happen even if you don't edit values in the column with the CoerceToListener because update queries, by default, compare all searchable columns in rows on the server.