Code examples

This section illustrates Java code samples 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 %SQLANYSAMP12%\UltraLiteJ\J2SE directory. It is recommended that you create backup copies of the original source code before modifying the file contents.

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.

The demo class found in %SQLANYSAMP12%\UltraLiteJ\J2SE\Demo.java is used by all the examples contained in this section of the documentation.

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

The output is saved in a file named demos.out.

 BlackBerry examples
 Android example
 See also

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