When you transfer data in either direction between the Java VM and Adaptive Server, you must take into account that the datatypes of the data items are different in each system. Adaptive Server automatically maps SQL items to Java items and vice versa according to the correspondence tables in “Datatype mapping between Java and SQL”.
Thus, SQL type char translates to Java type String, the SQL type binary translates to the Java type byte, and so on.
For the datatype correspondences from SQL to Java, char, varchar, and varbinary types of any length correspond to Java String or byte[ ] datatypes, as appropriate.
For the datatype correspondences from Java to SQL:
The Java String and byte[ ] datatypes correspond to SQL varchar and varbinary, where the maximum length value of 16K bytes is defined by Adaptive Server.
The Java BigDecimal datatype corresponds to SQL numeric(precision,scale), where precision and scale are defined by the user.
In the emps table, the maximum value for the Address and Address2Line classes, street, zip, and line2 fields is 255 bytes (the default value). The Java datatype of these classes is java.String, and they are treated in SQL as varchar(255).
An expression whose datatype is a Java object is converted to the corresponding SQL datatype only when the expression is used in a SQL context. For example, if the field home_addr>>street for employee ‘Smith’ is 260 characters, and begins ‘6789 Main Street ...:
select Misc.getStreet(home_addr>>street) from emps where name='Smith'
The expression in the select list passes the 260-character value of home_addr>>street to the getStreet( ) method (without truncating it to 255 characters). The getStreet( ) method then returns the 255-character string beginning ‘Main Street….’. That 255-character string is now an element of the SQL select list, and is, therefore, converted to the SQL datatype and (if need be) truncated to 255 characters.