UltraLite Static Java User's Guide
Data Access Using Pure Java
Building UltraLite Java applications
When you have prepared a reference database, defined an UltraLite project for your application, and added SQL statements to define your data access features, all the information the generator needs is inside your reference database.
For general information on the UltraLite generator, see Generating the UltraLite data access code. For command-line options, see The UltraLite generator.
The generator output is a Java source file with a filename of your choice. Depending on the design of your database and the sophistication of the database functionality your application requires, this file can vary greatly in both size and content.
There are several ways to customize the UltraLite generator output, depending on the nature of your application.
You generate the classes by running the UltraLite generator against the reference database.
To run the UltraLite generator
Enter the following command at a command-prompt:
ulgen -c "connection-string" options
where options depend on the specifics of your project.
When you are generating Java code, there are several options you may want to specify:
-t java Generate Java code. The generator is the same tool used for C/C++ development, so this option is required for all Java use.
-i Some Java compilers do not support inner classes correctly, and so the default behavior of the generator is not to generate Java code that includes inner classes. If you wish to take advantage of a compiler that does support inner classes, use this option.
-p It is common to include your generated classes in a package, which may include other classes from your application. You can use this switch to instruct the generator to include a package name for the classes in the generated files
-s In addition to the code for executing the SQL statements, generate the SQL statements themselves as an interface. Without this option, the strings are written out as members of the database class itself.
-a Make SQL string names upper case. If you choose the -a
option, the identifier used in the generated file to represent each SQL statement is derived from the name you gave the statement when you added it to the database. It is a common convention in Java to use upper case letters to represent constants. As the SQL string names are constants in your Java code, you should use this option to generate string identifiers that conform to the common convention.
The following command (which should be all on one line) generates code that represents the SQL statements in the CustDemo project, and the required database schema, with output in the file uldemo.java.
ulgen -c "dsn=Ultralite 9.0 Sample;uid=DBA;pwd=SQL" -a -t java -s IStatements CustDemo uldemo.java