Collection Contents Index Installing Java classes into a database Inserting, updating, and deleting Java objects pdf/chap17.pdf

User's Guide
   PART 3. Java in the Database
     CHAPTER 17. Using Java in the Database       

Creating columns to hold Java objects


This section describes how columns of Java class data types fit into the standard SQL framework.

Top of page  Creating columns with Java data types

You can use any installed Java class as a data type. You must use the fully qualified name for the data type.

For Info    For example, the following CREATE TABLE statement includes a column that has columns of Java data types asademo.Name and asademo.ContactInfo. Here, Name and ContactInfo are classes within the asademo package.

CREATE TABLE jdba.customer
(
   id    integer NOT NULL,
   company_name CHAR(35) NOT NULL,
   JName asademo.Name NOT NULL,
   JContactInfo asademo.ContactInfo NOT NULL,
   PRIMARY KEY (id)
)

Case sensitivity 

Unlike other SQL data types, Java data types are case sensitive. You must supply the proper case of all parts of the data type.

Top of page  Using defaults and NULL on Java columns

You can use defaults on Java columns, and Java columns can hold NULL entries.

Java columns and defaults     Columns can have as default values any function of the proper data type, or any preset default. You can use any function of the proper data type (that is, of the same class as the column) as a default value for Java columns.

Java columns and NULL     Java columns can allow NULL. If no default is set on a nullable column with Java data type, the column contains NULL.

If a Java value is not set, it has a Java null value. This Java null maps onto the SQL NULL, and you can use the IS NULL and IS NOT NULL search conditions against the values. For example, suppose the description of a Product Java object in a column named JProd was not set, you can query all products with non-null values for the description as follows:

SELECT *
FROM product
WHERE JProd>>description IS NULL

Top of page  Class constructors

An important part of handling Java classes in tables is the use of the class constructor. Properties of the constructor are as follows:

Top of page  

Collection Contents Index Installing Java classes into a database Inserting, updating, and deleting Java objects pdf/chap17.pdf