UltraLite Static Java User's Guide
Tutorial: Build an Application Using Java
The reference database for this tutorial is the UltraLite 9.0 Sample database. In a later step, you use this same directory as a consolidated database for synchronization. These two uses are separate, and in your work you may use different databases for the two roles.
Add the SQL statements to the reference database using the ul_add_statement stored procedure. In this simple application, use the following statements:
Insert An INSERT statement adds an initial copy of the data into the ULProduct table. This statement is not needed when synchronization is added to the application.
Select A SELECT statement queries the ULProduct table.
When you add a SQL statement, you must associate it with an UltraLite project. Here, we use a project name of Product. You must also add a name for the statement, which by convention is in upper case.
To add the SQL statements to the reference database
Start Sybase Central, and connect to the UltraLite 9.0 Sample data source using the Adaptive Server Anywhere plug-in.
Add a project to the database:
In Sybase Central, open the custdb database.
Open the UltraLite projects folder.
The folder contains one project already: the custapi project used for the sample application. You must create a new project.
Double-click Add UltraLite Project.
Enter Product as the project name, and click Finish.
Add the INSERT statement to the Product project.
Double-click Product to open the project.
Double-click Add UltraLite Statement.
Enter InsertProduct as the statement name. Click Next.
Enter the statement text:
INSERT INTO ULProduct ( prod_id, price, prod_name) VALUES (?,?,?)
The first argument is the project name, the second is the statement name, and the third is the SQL statement itself. The question marks in the SQL statement are placeholders, and you can supply values at runtime.
Click Finish to complete the operation.
This operation in Sybase Central is equivalent to executing the following stored procedure call:
call ul_add_statement( 'Product', 'InsertProduct', 'INSERT INTO ULProduct( prod_id, price, prod_name) VALUES (?,?,?) ' )
Add the SELECT statement to the Product project.
From the Product project, double-click Add UltraLite Statement.
Enter SelectProduct as the statement name. Click Next.
Enter the statement text:
SELECT prod_id, prod_name, price FROM ULProduct
Click Finish to complete the operation.
This operation in Sybase Central is equivalent to executing the following stored procedure call:
call ul_add_statement( 'Product', 'SelectProduct', 'SELECT prod_id, prod_name, price FROM ULProduct')
Close Sybase Central.
You have now added the SQL statements to the database, and you are ready to generate the UltraLite database.
For more information, see ul_add_project system procedure, and ul_add_statement system procedure.