void generateSchema(Vector entities, int numberOfGenerations, String journalTableDefinition) void generateSchema(Vector entities, int numberOfGenerations, String journalTableDefinition, String aSchemaName)
The application can specify the schema name, either by setting the schemaName attribute of the JDBCJournalSchemaGenerator instance (and then using the first method to generate the tables) or by passing the attribute as an argument to the generateSchema method (using the second method). If the application does not provide the schema name, the method uses the default value of DSESCHEM. If the schema does not have to be explicitly created in the database, the application must set the createSchema attribute to false before calling the generateSchema method (as when using DB2® UDB for OS/390® as the DBMS). In this situation, the JDBCJournalSchemaGenerator expects the schema identified by the schemaName attribute to be defined and accessible in the database.
If the journal tables are created in the default schema associated with a database user (in most DBMS such as DB2 and Oracle, when the DBMS creates a user, it assigns the user a default schema that has a name matching the user identification), the application must set the userDefaultSchema attribute to true before calling the generateSchema method This automatically sets the schemaName to the user name.
The first argument for both methods is a collection of strings with the names of the desired entities. The Vector of entities is mandatory, even if the journal is working with a unique entity. The second argument is the desired number of journal generations to be kept in the database. The third argument is a string with the SQL definition of the journal tables (without the record number DSERECN primary key, which is automatically added to the table definition).
The following is an example:
Vector entities= new Vector(3); entities.addElement("User1"); entities.addElement("User2"); entities.addElement("User3"); jsg = new JDBCJournalSchemaGenerator; String tableDefinition = "BRANCHNUMBER CHAR(4), AGREEMENTNUMBER INTEGER, DUEDATE DATE"; jsg.generateSchema(entities, 6, tableDefinition);
This sample creates 18 tables for the schema DSESCHEM with columns BRANCHNUMBER, AGREEMENTNUMBER, and DUEDATE, plus the extra column DSERECN. In addition, it creates the control table.
If you are using DB2 UDB for OS/390, you must specify the database name where the journal tables are created, because the database URL refers to a location where different databases can be defined; you can do this by using the setDatabaseName method. If the databaseName attribute is not null and not blank, the JDBCJournalSchemaGenerator creates the tables in the database specified by the databaseName attribute value within the location set in the database URL specification.
In addition, in a DB2 UDB for OS/390 environment, the JDBCJournalSchemaGenerator must explicitly create the indexes on the table's primary keys after it has created the tables. To do this, set the createIndex attribute to true.
The following table describes the JDBCJournalSchemaGenerator arguments, their default values, and when they should be set to a different value:
Attribute name | Description |
---|---|
schemaName | Contains the name of the journal schema. If you do not set this attribute, either explicitly or as an argument of the generateSchema method, the method uses the default value of DSESCHEM. If the userDefaultSchema attribute is set to true, the schemaName attribute is set to the name of the user creating the tables. Default value: DSESCHEM |
createSchema | Indicates whether the schema identified by schemaName must be explicitly
created before the tables are created. If you set this attribute to false,
the schema identified by schemaName must be already available in the database.
Default value: true |
createIndex | Indicates whether the indexes for the journal tables must be explicitly created after creating the tables. DB2 for NT/AIX and Oracle automatically create indexes on the table primary keys when the table is created. DB2 for OS/390 requires an explicit creation of the indexes after it creates the tables so you must set this attribute to true for this environment. Default value: false |
userDefaultSchema | Indicates whether the journal tables are going to be created in the default schema of the database user that is connected to the database. If you set this attribute to true, the value of the schemaName attribute value is not used. When the DBMS is Oracle, you can either set this attribute to true, in which case the DBMS creates the tables in the schema associated to the user executing the CREATE TABLE statement (the schema name matches the user name), or you can keep this attribute as false, in which case you must set the schemaName attribute to the schema of another user and set the createSchema attribute to false. Default value: false |
databaseName | Keeps the database name when working with DB2 UDB in OS/390. In this environment the database URL as set in the database connection has the following format: jdbc:db2os390:<location>. The <location> is the name of a shared database subsystem with different databases and storage groups defined in it. The databaseName attribute indicates which database contains the table. If you do not specify a value, the DBMS creates the journal tables in the default database within this location. |