Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » UltraLiteJ » Using UltraLiteJ » Tutorial: Build a BlackBerry application » Part 1: Creating an UltraLiteJ application on BlackBerry


Lesson 4: Create a database table

In this lesson, you create a simple table called Names, which contains two columns that have the following properties:

Column name Data type Allow null? Default Primary key?
ID UUID No None Yes
Name Varchar(254) No None No
  1. Add a DataAccess method to create the table.
    private void createDatabaseSchema()
            ColumnSchema column_schema;
            TableSchema table_schema = _conn.createTable("Names");
            column_schema = table_schema.createColumn( "ID", Domain.UUID );
            column_schema.setDefault( ColumnSchema.COLUMN_DEFAULT_UNIQUE_ID);
            table_schema.createColumn( "Name", Domain.VARCHAR, 254 );
            IndexSchema index_schema =
            index_schema.addColumn("ID", IndexSchema.ASCENDING);           
        catch( ULjException uex1){
            System.out.println( "ULjException: " + uex1.toString() );
        catch( Exception ex1){
            System.out.println( "Exception: " + ex1.toString() );

    If the table already exists, an exception is thrown.

  2. Call the DataAccess.getDataAccess method.

    Add the following code before the method returns:

    return _da;
  3. Run the application again in the simulator.
Altering the table schema

When you alter the table schema, for example, by adding a table definition, you must keep the following information in mind: