![]() |
Storing Objects and Classes
|
|
Storing Classes in the DatabaseNOTE: This is an advanced topic. You can store application logic in a database and then have Cloudscape and your application load classes from the database instead of from the user's class path. Application logic, which can be used by both Cloudscape and your application, includes Java class files and other resources. In the JBMSTours application, the City class is an example of application-side logic that is used by both Cloudscape and the application. Storing application code simplifies application deployment, because it reduces the potential for problems with a user's class path. To store classes in a database, you first must package up the class files (and any resources used by the application) into a jar file. Then you load the jar file into the database with a special utility and enable Cloudscape to load classes from a database. Finally, you use a special bootstrap mechanism for executing the application so that it uses the Cloudscape class loader. In this section, you will package up the class files in the JBMSTours package into a jar file and try to run the application using the Cloudscape class loader. You will no longer need %CLOUDSCAPE_INSTALL%/demo/programs/tours in your class path to run the JBMSTours application, because all application logic will now be stored in the database. Create a Jar File for the JBMSTours Package and SubpackagesYou can use the standard jar utility to create a jar file for the JBMSTours package.
NOTE: The jar utility recognizes forward slashes on all platforms.
Add the Jar File to the Database as ToursLogicYou will add the jar file to the toursDB database, giving it a Cloudscape name when you do so. This name will be ToursLogic. You will modify it with APP, the schema name. Cloudview makes it easy to work with jar files.
Alter the Value of Your Class PathWhen loading classes, Cloudscape always looks in the class path first, then in the jar files stored in the database. To make sure Cloudscape loads files from the database, remove the %CLOUDSCAPE_INSTALL%/demo/programs/tours directory from your class path.
Run JBMSTours.GenerateReport with Class Loading from the DatabaseOnce you enable database class loading (which you did in Add the Jar File to the Database as ToursLogic) and remove loadable classes from the class path, Cloudscape will load the classes from the database. Cloudscape provides an application bootstrap program that forces Cloudscape class loading for your application. The program is called COM.cloudscape.util.DBClassLoad.
|
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |