Using Java with Caché Jalapeño
Using Jalapeño Tools
Jalapeño includes several tools for tasks such as connecting to the database, generating Caché schema, and creating test data. This chapter discusses how to call these tools from the command line or a script file. The following topics are covered:
Generating Caché Classes with SchemaBuilder
The Jalapeño SchemaBuilder is used to generate Caché classes from your Java source files.
Running SchemaBuilder from the Command Line
To start SchemaBuilder from the command line, use a command of the form:
java -cp <cachejars> com.jalapeno.tools.SchemaBuilder -f <properties>
java -cp .;"%cachejars%/cachejdbc.jar";"%cachejars%/cachedb.jar"
Alternately, you can use the SchemaBuilder -fd
switch, which does not take a filename as an argument. Instead, SchemaBuilder attempts to find a file in the current directory with the default name SchemaBuilder.properties
. This default file must contain all required connection properties
, including a valid password.
Defining SchemaBuilder Properties
SchemaBuilder properties define the parameters that determine how and where the Caché classes are generated. When SchemaBuilder is run from the command line, it reads these properties from a file in the standard java.util.Properties
SchemaBuilder properties are grouped into the following categories:
The properties file must contain all required connection information, including a valid password. If SchemaBuilder cannot find a valid properties file, it will not be able to open a connection to Caché, and will exit with the following error message:
[Cache JDBC] Communication link failure: Access Denied
The examples in the following sections use standard property file syntax, which requires all colons and backslashes to be escaped with a backslash. A backslash may also be used as a line continuation character. For example:
name of an optional JDBC log file (line breaks have been added to this example for clarity).
type of object/relational mapping notation used in the Java source classes.
list of packages to be excluded when generating Caché classes.
specifies whether the generated class information should be merged into pre-existing versions of the same classes.
Calling KillExtent from the Command Line
KillExtent is used to delete all instances of specified classes and their subclasses from the database. It can be called by specifying the classes to be deleted and the namespace where they are located. Standard connection parameters can be specified; otherwise, the default connection parameters are used. The class path must include paths for cachedb.jar
and all of the class files to be deleted. For example:
java -cp <Path To class files>;<Path To cachedb.jar>
The following example explicitly specifies all five connection parameters:
java -cp <Path To class>;<Path To CacheDB>\cachedb.jar
SchemaBuilder Properties Reference
Connection properties are the JDBC driver parameters used to connect to the Caché database. All of the tools discussed in this chapter use these properties.
The URL is a string constructed from a JDBC driver name plus the host
, and user
properties. It has the following format:
For example, the sample programs in this book use the following connection string:
file contains the Caché version of the JDBC driver.
The server TCP/IP address or Fully Qualified Domain Name (FQDN). The sample programs use "localhost"
), assuming that both the server and the application are on the same machine.
The TCP/IP superserver port number for this connection. Together, the IP address and the port specify a unique Caché server. Your Caché superserver port number is set in the Caché Management Portal under [System Administration] > [Configuration] > [System Configuration] > [Memory and Startup]
The Caché namespace containing the objects to be used. This namespace must have the Caché system classes compiled, and must contain the objects you want to manipulate. The sample programs use objects from the SAMPLE
The username under which the connection is being made. The sample programs use "_SYSTEM"
, the default SQL System Manager username.
The password associated with the specified username. Sample programs use the default, "SYS"
Optional. Specifies the name of a JDBC log file to be written when the application attempts to make a connection.
SchemaBuilder Introspection Properties
These properties determine the methods used to generate the Caché classes.
Specifies the ORM (Object/Relational Mapping) metadata notation to be used in the Java source classes. Possible values are:
Specifies the minimum access level that a property must have in order to be included in the generated Caché class. For example, if the required access level is protected
, then Private properties will not be included. Possible values are:
all properties will be included.
only Public and Protected properties will be included.
only Public properties will be included).
Specifies the least restrictive access type that a property must have in order to be included in the generated Caché class. For example, if the required access type is properties
, then only properties that have both get and set accessors will be included. Possible values are:
include both Public fields and properties with accessors (get and set methods).
include only properties with accessors.
If this property is true
, SchemaBuilder will attempt to merge the generated classes with any pre-existing versions of the same classes in Caché. If this property is false
, the previous classes will be deleted when the new ones are generated.
SchemaBuilder File Properties
These properties specify the files that will be used when generating the Caché classes.
Specifies the parent directory of directories containing *.class
source files to be used.
Specifies whether your Java source classes are stored as standard *.class
files, or are compressed into *.jar
files. Valid options are:
The default value is jars
Specifies a list of the source files that will be used to generate Caché classes. The list can contain either compressed (*.jar
) files or *.class
files, but not both. If the list contains multiple items, they must be separated by semicolons.
files a list of the Java class files.
files a list of compressed files containing the Java source classes.
SchemaBuilder Projection Properties
These properties specify settings for optional generation of projected Java classes.
Projected Java classes will be placed in a package with the name specified by this property.
A set of flags that determine which types of projection file will be produced.
2 Interface files (used by both Native and POJO projections).
4 Native Caché projection files.
8 POJO projection files.
For example, a value of 10 would indicate that both Interface and POJO (2+8) files should be generated. The default value is "0" (no projection files are generated).
Specifies the base directory that will contain the projected Java files. A subdirectory with the same name as the package will be created within the projection directory. Interface and POJO projections will be placed directly in <projectiondir>\<packagename>
. Native projections will be placed in <projectiondir>\<packagename>\cache