Coding examples

This section illustrates examples of Java code that utilize the UltraLiteJ API. The examples use a demo class that displays messages and handles ULjException objects for debugging purposes.

All coding examples can be found in the samples-dir\UltraLiteJ directory. It is recommended that you create backup copies of the original source code before modifying the file contents. For information about the default location of samples-dir, see Samples directory.

Although these code examples are written for the Windows desktop environment, the concepts presented apply to all UltraLiteJ platforms (unless otherwise noted).

To run these examples, set your JAVA_HOME environment variable to an installed version of the JDK 1.6. You can then run rundemo.cmd with the name of the example.

For example, the following command runs the CreateDb sample:

rundemo CreateDb

The command produces the following output:



Executing:
CREATE TABLE department
( dept_no INT NOT NULL PRIMARY KEY
, name VARCHAR(50)
)

Executing:
CREATE TABLE Employee
( number INT NOT NULL PRIMARY KEY
, last_name VARCHAR(32)
, first_name VARCHAR(32)
, age INT
, dept_no INT
, FOREIGN KEY fk_emp_to_dept( dept_no ) REFERENCES department( dept_no ))

CreateDb completed successfully

All the output into a file called demos.out.

 BlackBerry examples

Example: Demo class
Example: Creating a database
Example: Inserting rows
Example: Reading a table
Example: Inner join operations
Example: Creating a sales database
Example: Aggregation and grouping
Example: Retrieving rows in an alternative order
Example: Modifying table definitions
Example: Obfuscating data
Example: Encrypting data
Example: Displaying database schema information
Example: Synchronizing a database