The following sections provide instructions on how to create a database OTD.
The Database OTD Wizard generates OTDs by connecting to external data sources and creating corresponding Object Type Definitions. The OTD Wizard can create OTDs based on any combination of Tables, Stored Procedures, or Prepared Statements.
Field nodes are added to the OTD based on the Tables in the external data source. Java method and parameter nodes are added to provide the appropriate JDBC functionality. For more information about the Java methods, refer to your JDBC developer’s reference. Each of the database adapters below provides additional support, such as the Sybase adapter which supports double-byte character set (DBCS). The DBCS is a set of characters in which each character is represented by 2 bytes. The Korean language requires double-byte character sets.
The following topics are discussed:
The Database OTD Wizard generates OTDs by connecting to external data sources and creating corresponding Object Type Definitions. The OTD Wizard can create OTDs based on any combination of Tables and Stored Procedures or Prepared SQL Statements. Field nodes are added to the OTD based on the Tables in the external data source. Java method and parameter nodes are added to provide the appropriate JDBC functionality. For more information about Java methods, refer to your JDBC developer’s reference guide.
Database OTDs are not messagable. For more information on messagable OTDs, see the Enterprise Service Bus User’s Guide
The following steps are required to create a new OTD for the DB2 UDB Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the project tree list, right click on the project and select Create an Object Type Definition from the shortcut menu.
From the OTD Wizard Selection window, select the DB2 Database and click Next (see the following figure).
Select the Connection type using the drop-down list (see the following figure). The rest of the Connection Information fields displayed will depend on your selection.
Specify the applicable connection information (depending on the Connection type) for your database including:
Host Name - The server where DB2 resides.
Port - The port number of DB2.
Location (AS/400 and z/OS specific) - The name of the DB2 subsystem. To find the location of the DB2 subsystem, use the Database Query Tool to issue the following query: select current server from sysibm.sysdummy1.
Database (Windows/Unix specific) - The name of the database instance.
Collection (AS/400 and z/OS specific) - The name that identifies a group of packages. For more information on Packages, refer to Packages.
User Name - The user name that the adapter uses to connect to the database.
Password - The password used to access the database.
An Optional Parameters field (only for AS/400 and z/OS) will display in the OTD Wizard if the DB2_ConnectionInfo.txt file is present in the netbeans\usrdir\modules\ext\ db2adapter directory. This field allows additional connection parameters for the DB2 OTD wizard. Please contact Sun Microsystems, Inc. for more information on Optional Parameters.
This parameter is not specific to an OTD. It’s only specific to the session where Java CAPS IDE runs. When you edit the OTD, the current value that shows up is the value that was entered previously in the Wizard. It may or may not be the same value you used for creating the original OTD.
Parameter examples include:
The showSelectableTables=false parameter can be set to false (default is true) to see additional tables listed under a user, such as the behavior in a previous Adapter which uses an older version of the driver.
The AlternateID=user1 parameter allows you to set the object owner to be user1 otherwise the user in the User Name field will be used.
Multiple parameters can be used and must be separated by a semi-colon (;).
Click Next. The Select Database Objects window appears.
This Adapter uses a DataDirect driver (previously known as Merant) to execute SQL calls in DB2. The DataDirect driver requires packages to be created in the DB2 System. Packages do not contain specific SQL statements like static SQL packages but rather dynamic sections, used like cursors to help facilitate the driver’s executing of dynamic SQL queries and returning results.
Creating packages on the server, also known as binding packages, needs only be done once. The first user of the OTD Wizard must have bind permission to create the packages. Without bind authority the user receives an error message when the driver attempts to bind the packages and they will be unable to issue any SQL call. Packages are created automatically, under the Collection ID, when the user fills in the Wizard entries. If the Collection ID is left as blank, it will generate the packages under NULLID.
The driver creates SQL packages on the database including: DDJC330A, DDJC330B, DDJC330C, etc. When connecting, the driver queries a system table to determine whether the default packages exist on the system. If none exist, the driver creates them.
SQL applications that execute dynamic SQL against DB2 need to have packages bound on the server. In the case of some IBM native tools this may not be obvious because the packages are already installed on the database by default.
When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the .otd file. Click Next to continue (see the following figure).
Click Next to continue. The Select Tables/Views window appears.
Views are read-only and are for informational purposes only.
In the Select Tables/Views/Aliases window, click Add (see the following figure).
In the Add Tables window, select the type of criteria to be used for your search, consisting of table data, view only data, or both. You can include system tables in your search by selecting the checkbox.
From the Table/View Name drop down list, select the location of your database table and click Search. You can search for Table/View Names by entering a table name. The use of wildcard characters of ”?’, and ”*’ as part of your Table/View name search allow for greater search capabilities. For example, “AB?CD” or “AB*CD”.
Select the table of choice and click OK. The table selected is added to the Selected window (see the following figure).
On the Selected Tables/Views window, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
If you clicked Change on the Selected Tables/Views window, you can select or deselect your table columns on the Table/View Columns window. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down (see the following figure).
Click Advanced to change the data type, precision/length, or scale. In general, do not change the precision/length or the scale. Once you have finished your table choices, click OK (see the following figure).
On the Select Procedures and specify Resultset and Parameter Information window, click Add.
On the Select Procedures window, enter the name of a Procedure or select a table from the drop down list. Click Search. Wildcard characters can also be used.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
On the Select Procedures and specify Resultset and Parameter Information window click Edit Parameters to make any changes to the selected Procedure (see the following figure).
To restore the data type, click Restore. When finished, click OK.
To select how you would like the OTD to generate the nodes for the Resultset click Edit Resultsets.
Click Add to add the type of Resultset node you would like to generate.
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are the "By Executing", "Manually", and "With Assistance" modes.
By Executing Mode — “By Executing” mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes.
With Assistance Mode — "With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query.
Manually Mode — "Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
SELECT A, B, 3*C FROM table T |
is generated by the database. In this case, "With Assistance" mode is a better choice.
If you modify the ResultSet generated with the by the “By Executing Mode” of the Database Wizard, you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved.
When using Prepared Statement packages, select Use fully qualified table/view names in the generated Java code.
A Prepared Statement OTD represents a SQL statement that has been compiled. Fields in the OTD correspond to the input values that users need to provide.
Prepared statements can be used to perform insert, update, delete and query operations. A prepared statement uses a question mark (?) as a place holder for input. For example: insert into EMP_TAB (Age, Name, Dept No) values (?, ?, ?)
To execute a prepared statement, set the input parameters and call executeUpdate() and specify the input values if any.
When using a Prepared Statement, the ”ResultsAvailable()’ method will always return true. Although this method is available, you should not use it with a ”while’ loop. Doing so would result in an infinite loop at runtime and will stop all of the system’s CPU. If it is used, it should only be used with the ”if’ statement. You can process a resultset by looping through the next() method.
On the Add Prepared Statements window, click Add.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. When finished creating the statement, click Save As giving the statement a name. This name appears as a node in the OTD. Click OK (see the following figure).
On the Add Prepared Statement window, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
When doing a Prepared Statement with two or more tables, where multiple tables have the same column name, you must put the table name qualifier in the Prepared Statement to build the OTD.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK (see the following figure).
To edit the Resultset Columns, click Edit Resultset Columns. Both the Name and Type are editable but it is recommend you do not change the Name. Doing so will cause a loss of integrity between the Resultset and the Database. Click OK (see the following figure).
The OTD Wizard fails to create OTDs with complex prepared statements that use the same column name in different tables. This problem is resolved by modifying the SQL statement to use column name aliases.
On the Add Prepared Statements window, click OK.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes (see the following figure).
Click Next.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD (see the following figure).
The resulting OTD appears on the Java CAPS IDE’s canvas.
A single OTD can consist of many Database objects. They can be a mixture of Tables, Prepared Statements and Stored Procedures. By using the Database OTD Wizard, the OTD Edit feature allows you to:
Add or Remove Table/Views.
Change data types by selecting a different one from a list.
Add or Remove columns from a Table object.
Add or Remove Prepared Statement objects.
Edit Prepared Statement objects.
Add or Remove Stored Procedure objects.
Edit Stored Procedure Resultsets.
When a minor change is needed for an existing OTD, there is no need to rebuild it from scratch; instead, you can edit the OTD. To edit an OTD, complete the following steps:
In the project tree list, right-click on the OTD. From the submenu, click Edit. The Database Connection Information Wizard opens.
Connect to the DB2 database by entering the applicable information in the wizard. Once the connection is established, the Database Wizard opens, allowing you to make modifications to the OTD.
Once you have completed editing the OTD, click the Finish button to save the changes.
Once the OTD has been edited, you must verify that the changes are reflected in the Collaboration so that no errors occur at runtime. For example, if during the edit process, you delete a database object that is included in a Collaboration, the Collaboration could fail at build or run-time.
When editing an OTD, you can connect to another instance of the database under the following conditions:
The same type of DB2 database must be used. Because of incompatibility of certain features in the databases, switching between DB2 databases that run on z/OS, AS/400 and Windows/UNIX is not supported.
The same version of the database should be used unless the newer version is compatible with the older version.
Tables in the database must be defined with the same definition.
The stored procedures must be identical.
For tables/stored procedures built with 'qualified-name’, the schema name for the tables/stored procedures must be identical in both database instances.
The Database OTD Wizard generates OTDs by connecting to external data sources and creating corresponding Object Type Definitions. The OTD Wizard can create OTDs based on any combination of Tables and Stored Procedures or Prepared SQL Statements. Field nodes are added to the OTD based on the Tables in the external data source. Java method and parameter nodes are added to provide the appropriate JDBC functionality. For more information about the Java methods, refer to your JDBC developer’s reference.
Database OTDs are not messagable. For more information on messagable OTDs, see the Sun Enterprise Service Bus User’s Guide.
The following steps are required to create a new OTD for the DB2 Connect Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the project tree, right click on the project and select Create an Object Type Definition from the shortcut menu.
From the OTD Wizard Selection window, select the DB2 Connect Database and click Next (see the following figure).
Enter the DB2 Connect connection information in the Connection Information frame.
Select the Connection type using the drop-down list (see the following figure). The resulting Connection Information fields displayed will depend on your selection (i.e. selecting a Type 2 or Type 4 connector).
Specify the applicable connection information (depending on the Connection type) for your database including:
For the Type 2 Connection (shown above):
Database - The name of the database instance.
User Name - The user name that the Adapter uses to connect to the database.
Password - The password used to access the database.
For the Type 4 Connection(shown above):
Host Name - The server where DB2 Connect resides.
Port - The port number of DB2 Connect.
Database - The name of the database instance that the DB2 is running on Windows/Unix. The name of the locator for the DB2 running in z/OS or AS/400.
User Name - The user name that the adapter uses to connect to the database.
Password - The password used to access the database.
Click Next. The Select Database Objects window appears.
Select the type of DB2 Connect objects you want included in the OTD.
When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the .otd file. Click Next to continue. (See the following figure).
Views are read-only and are for informational purposes only.
Click Next to continue. The Select Tables/Views/Aliases window appears.
Select the types of tables or views required in the OTD.
In the Select Tables/Views window, click Add (see the figure below).
In the Add Tables window, select the type of criteria to be used for your search, consisting of table data, view only data, or both. You can include system tables in your search by selecting the checkbox.
From the Table/View Name drop down list, select the location of your database table and click Search (see the following figure). You can search for Table/View Names by entering a table name. The use of wildcard characters of ”?’, and ”*’ as part of your Table/View name search allow for greater search capabilities. For example, “AB?CD” or “AB*CD”.
Select the table of choice and click OK. The table selected is added to the Selected window (see the following figure).
On the Selected Tables/Views window, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
If you clicked Change on the Selected Tables/Views window, you can select or deselect your table columns on the Table/View Columns window. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down (see the following figure).
Click Advanced to change the data type, precision/length, or scale. In general, do not change the precision/length or the scale. Once you have finished your table choices, click OK (see the following figure).
When using Prepared Statement packages, select Use fully qualified table/view names in the generated Java code.
Select the procedure required in the OTD.
On the Select Procedures and specify Resultset and Parameter Information window, click Add.
On the Select Procedures window, enter the name of a Procedure or select a table from the drop down list. Click Search. Wildcard characters can also be used.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
On the Select Procedures and specify Resultset and Parameter Information window click Edit Parameters to make any changes to the selected Procedure. (see the following figure).
To restore the data type, click Restore. When finished, click OK.
To select how you would like the OTD to generate the nodes for the Resultset click Edit Resultsets.
Click Add to add the type of Resultset node you would like to generate (see the following figure).
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are the "By Executing", "Manually", and "With Assistance" modes.
By Executing Mode |
“By Executing” mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes. |
|
With Assistance Mode |
"With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query. |
|
Manually Mode |
"Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
is generated by the database. In this case, "With Assistance" mode is a better choice. If you modify the ResultSet generated by the “Execute” mode of the Database Wizard you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved. |
On the Select Procedures and specify Resultset and Parameter Information window click Next to continue.
A Prepared Statement OTD represents a SQL statement that has been compiled. Fields in the OTD correspond to the input values that users need to provide. Prepared statements can be used to perform insert, update, delete and query operations. A prepared statement uses a question mark (?) as a place holder for input. For example: insert into EMP_TAB (Age, Name, Dept No) values (?, ?, ?)
To execute a prepared statement, set the input parameters and call executeUpdate() and specify the input values if any.
When using a Prepared Statement, the ”ResultsAvailable()’ method will always return true. Although this method is available, you should not use it with a ”while’ loop. Doing so would result in an infinite loop at runtime and will stop all of the system’s CPU. If it is used, it should only be used with the ”if’ statement.You can process a resultset by looping through the next() method.
On the Add Prepared Statements window, click Add.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. When finished creating the statement, click Save As giving the statement a name. This name will appear as a node in the OTD. Click OK (see the following figure).
On the Add Prepared Statement window, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the data type by clicking in the Type field and selecting a different type from the list.
When doing a Prepared Statement with two or more tables, where multiple tables have the same column name, you must put the table name qualifier in the Prepared Statement to build the OTD.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK. (see the following figure).
To edit the Resultset Columns, click Edit Resultset Columns. Both the Name and Type are editable but it is recommend you do not change the Name. Doing so will cause a loss of integrity between the Resultset and the Database. Click OK (see the following figure).
The OTD Wizard fails to create OTDs with complex prepared statements that use the same column name in different tables. This problem is resolved by modifying the SQL statement to use column name aliases.
On the Add Prepared Statements window, click OK.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD.
The OTD contains the selected tables and the package name of the generated classes (see the following figure).
Click Next to continue. The Review your Selections window appears.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD (see the following figure).
The resulting OTD appears on the Java CAPS IDE’s canvas.
A single OTD can consist of many Database objects. They can be a mixture of Tables, Prepared Statements and Stored Procedures. By using the Database OTD Wizard, the OTD Edit feature allows you to:
Add or Remove Table/Views.
Change data types by selecting a different one from a list.
Add or Remove columns from a Table object.
Add or Remove Prepared Statement objects.
Edit Prepared Statement objects.
Add or Remove Stored Procedure objects.
Edit Stored Procedure Resultsets.
When a minor change is needed for an existing OTD, there is no need to rebuild it from scratch; instead, you can edit the OTD.
In the project tree, right-click on the OTD. From the submenu, click Edit. The Database Connection Information Wizard opens.
Connect to the database by entering the applicable information in the wizard. Once the connection is established, the Database Wizard opens, allowing you to make modifications to the OTD.
Once you have completed editing the OTD, click the Finish button to save the changes.
Once the OTD has been edited, you must verify that the changes are reflected in the Collaboration so that no errors occur at runtime. For example, if during the edit process, you delete a database object that is included in a Collaboration, the Collaboration could fail at activation or run-time.
When editing an OTD, you can connect to another instance of the database under the following conditions:
The same version of the database should be used unless the newer version is compatible with the older version.
Tables in the database must be defined with the same definition.
The stored procedures must be identical.
For tables/stored procedures built with qualified-name, the schema name for the tables/stored procedures must be identical in both database instances.
The following steps are required to create a new OTD for the Informix Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the Project tree, right click the Project and select New > Object Type Definition from the shortcut menu. The Select Wizard Type page appears, displaying the available OTD wizards.
From the New Object Type Definition Wizard window, select the Informix Database and click Next. See the following figure.
From the New Object Type Definition Wizard window, select Informix Database and click the Next button. The New Wizard - Informix Database window appears.
Enter the Informix database connection information in the Connection Information frame.
Required Database Connection Fields include:
Host name– the name of the host to which you are connecting.
Port ID– the host port number (1526 is the default).
Informix Server– the name of the Informix server.
Database name– the name of the database to which you are connecting.
User name– a valid Informix database username.
Password– a password for the user name noted above.
Click Next. The Select Database Objects window appears.
Select the type of Informix database objects you want included in the OTD.
Steps Required to Select Database Objects Include:
When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the OTD file. Click Next to continue. See the following figure.
Views are read-only and are for informational purposes only.
Select the types of tables, views, or aliases required in the OTD.
Steps Required to Select Table/Views/Aliases Include:
In the Select Tables/Views/Aliases window, click Add. See the following figure.
In the Add Tables window, select if your selection criteria will include table data, view only data, both, and/or system tables.
From the Table/View Name drop down list, select the location of your database table and click Search. See the following figure.
Select the table of choice and click OK.
The table selected is added to the Selected Tables/Views/Aliases section (see the following figure).
In the Selected Tables/Views/Aliases section, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
In the Table/View Columns window, you can select or deselect your table columns. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down list. If you would like to change any of the tables columns, click Change. See the following figure.
The data type is usually listed as Other when the driver cannot detect the data type. In these situations we recommend changing the data type to one that is more appropriate for the type of column data.
Click Advanced to change the data type, percision/length, or scale. Once you have finished your table choices, click OK. In general, you will not need to make any changes.
The Informix database driver currently deployed with the Informix adapter displays non-nullable columns in the OTD wizard dialogue box regardless of whether the columns in the database accept null values or not.
Select the type of stored procedures required in your OTD.
Steps Required to Select Stored Procedures Include:
On the Select Procedures and specify Resultset and Parameter Information window, click Add.
On the Select Procedures window, enter the name of a Procedure or select a table from the drop down list. Click Search. Wildcard characters can also be used.
You must use lower case schema names when calling stored procedures.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
The Informix database driver currently deployed with the Informix adapter does not return metadata to provide fully the type of stored procedure available when a search is executed. Thus the Type field for all procedures will be populated with “Unknown.”
On the Select Procedures and specify Resultset and Parameter Information window click Edit Parameters to make any changes to the selected Procedure.
To restore the data type, click Restore. When finished, click OK.
To select how you would like the OTD to generate the nodes for the Resultset click Edit Resultsets.
Click Add to add the type of Resultset node you would like to generate.
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are "By Executing", "Manually", and "With Assistance" modes.
"By Executing" mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes.
"With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query.
"Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
SELECT A, B, 3*C FROM table T |
is generated by the database. In this case, "With Assistance" mode is a better choice.
If you modify the ResultSet generated by the “Execute” mode of the Database Wizard you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved.
On the Select Procedures and specify Resultset and Parameter Information window click Next to continue.
Add a Prepared Statement object to your OTD.
Steps Required to Add Prepared Statements Include:
When using a Prepared Statement, the ”ResultsAvailable()’ method will always return true. Although this method is available, you should not use it with a ”while’ loop. Doing so would result in an infinite loop at runtime and will stop all of the system’s CPU. If it is used, it should only be used with the ”if’ statement.
On the Add Prepared Statements window, click Add. The Add Prepared Statement window appears.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. When finished creating the statement, click Save As giving the statement a name. This name will appear as a node in the OTD. Click OK. See the following figure.
On the Add Prepared Statement window, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK. Figure 1–21.
To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
Click Add to add a new ResultSet column. Both the Name and Type are editable.
Click OK to return to the Add Prepared Statements window.
Specify the name that your OTD will display in the Java CAPS IDE.
Steps Required to Specify the OTD Name:
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes. See the following figure.
Click Next.
Review the selections made for the new OTD.
Steps Required to Review Your OTD Selections:
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD. See the following figure.
The resulting OTD appears on the Java CAPS IDE.
You can edit any database OTD you create directly from the Java CAPS IDE.
Unlock the OTD. To do this, right-click the OTD in the Project tree and select Version Control > Check Out from the menu.
The Version Control - Check Out window appears.
Select the OTD you want to check out, then click Check Out.
From the Project tree, right-click the OTD again and select Edit from the menu.
The Informix Database Connection Information wizard appears.
Enter the connection information as described in To Connect to a Database, and click Next.
Step through each of the wizard steps and click Finish to save your changes.
You must verify during project activation or at runtime that no errors are generated after editing an OTD. Errors could occur if you delete a database object that is included in a Collaboration.
The following steps are required to create a new OTD for the JDBC Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the Project tree, right click the Project and select New ⇒ Object Type Definition from the shortcut menu. The Select Wizard Type page appears, displaying the available OTD wizards. See the following figure.
From the New Object Type Definition Wizard window, select JDBC Database and click the Next button. The New Wizard - JDBC Database window appears.
Enter the JDBC database connection information in the Connection Information frame.
Required Database Connection Fields include:
Driver Jar Files– the location of the driver JAR file.
Driver Java Class Name– the name of the Driver Manager Class.
URL Connection String– the URL connection string for the driver.
User name– a valid JDBC database username.
Password– a password for the user name noted above.
Select the type of JDBC database objects you want included in the OTD.
When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the OTD file. Click Next to continue. See the following figure.
Views are read-only and are for informational purposes only.
Select the types of tables, views, or aliases required in the OTD.
In the Select Tables/Views/Aliases window, click Add. See the following figure.
In the Add Tables window, select if your selection criteria will include table data, view only data, both, and/or system tables.
From the Table/View Name drop down list, select the location of your database table and click Search. See the following figure.
Select the table of choice and click OK.
The table selected is added to the Selected Tables/Views/Aliases section. See the following figure.
In the Selected Tables/Views/Aliases section, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
In the Table/View Columns window, you can select or deselect your table columns. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down list. If you would like to change any of the tables columns, click Change. See the following figure.
The data type is usually listed as Other when the driver cannot detect the data type. In these situations we recommend changing the data type to one that is more appropriate for the type of column data.
Click Advanced to change the data type, precision/length, or scale. Once you have finished your table choices, click OK. In general, you will not need to make any changes. See the following figure.
Select the type of stored procedures required in your OTD.
On the Select Procedures and specify Resultset and Parameter Information window, click Add.
On the Select Procedures window, enter the name of a Procedure or select a schema from the drop down list. Click Search. Wildcard characters can also be used.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
On the Select Procedures and specify Resultset and Parameter Information window click Edit Parameters to make any changes to the selected Procedure. See the following figure.
To restore the data type, click Restore. When finished, click OK.
To select how you would like the OTD to generate the nodes for the Resultset click Edit Resultsets.
Click Add to add the type of Resultset node you would like to generate.
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are "By Executing", "Manually", and "With Assistance" modes.
By Executing Mode |
“By Executing” mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes. |
|
With Assistance Mode |
"With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query. |
|
Manually Mode |
"Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
is generated by the database. In this case, "With Assistance" mode is a better choice. If you modify the ResultSet generated by the “Execute” mode of the Database Wizard you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved. |
On the Select Procedures and specify Resultset and Parameter Information window click Next to continue.
Not all drivers and databases support stored procedures or stored procedures with ResultSets. You may contact the driver’s vendor for more information.
Add a Prepared Statement object to your OTD.
When using a Prepared Statement, the ResultsAvailable() method will always return true. Although this method is available, you should not use it with a while loop. Doing so would result in an infinite loop at runtime and will stop all of the system’s CPU. If it is used, it should only be used with the if statement.
On the Add Prepared Statements window, click Add.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. When finished creating the statement, click Save As giving the statement a name. This name will appear as a node in the OTD. Click OK. See the following figure.
On the Add Prepared Statement window, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK. See the following figure.
To edit Resultset Columns, click Edit Resultset Columns. The ResultSet Columns window appears. See the following figure.
Click Add to add a new ResultSet column. Both the Name and Type are editable.
Click OK to return to the Add Prepared Statements window.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes. See the following figure.
Click Next.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD. See the following figure.
The resulting OTD appears on the Java CAPS IDE.
You can edit any database OTD you create directly from theJava CAPS IDE.
Unlock the OTD. To do this, right-click the OTD in the Project tree and select Version Control ⇒ Check Out from the menu.
The Version Control - Check Out window appears.
Select the OTD you want to check out, then click Check Out.
From the Project tree, right-click the OTD again and select Edit from the menu.
The JDBC Database Connection Information wizard appears.
Enter the connection information as described in To Connect To Database, and click Next.
Step through each of the wizard steps and click Finish to save your changes.
You must verify during project activation or at runtime that no errors are generated after editing an OTD. Errors could occur if you delete a database object that is included in a Collaboration.
The following steps are required to create a new OTD for the Oracle adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the project tree, right click the Project and select New ⇒ Object Type Definition from the shortcut menu. The Select Wizard Type page appears, displaying the available OTD wizards.
From the New Object Type Definition Wizard window, select the Oracle Database and click Next. (see the following figure).
Enter the Oracle database connection information in the Connection Information frame.
Specify the applicable connection information for your database including:
Host Name - The server where Oracle resides.
Port ID- The port number of Oracle.
SID - The name of the Oracle instance (equivalent to the database name).
User Name - The user name that the Adapter uses to connect to the database.
Password - The password used to access the database.
Click Next. The Select Database Objects window appears.
Select the type of Oracle database objects you want included in the OTD.
In the Select Database Objects dialog box (shown below), select Tables/Views for this sample. When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the .otd file. Click Next to continue.
Views are read-only and are for informational purposes only.
Click Next to continue. The Select Tables/Views/Aliases window appears (depending on your selection).
Select the types of tables or views required in the OTD.
Aliases are not supported in the current release of the Oracle Adapter.
In the Select Tables/Views/Aliases window, click Add (see the figure below).
In the Add Tables window, select the type of criteria to be used for your search, consisting of table data, view only data, or both. You can include system tables in your search by selecting the checkbox.
From the Table/View Name drop down list, select the location of your database table and click Search. You can search for Table/View Names by entering a table name. The use of wildcard characters of ”?’, and ”*’ as part of your Table/View name search allow for greater search capabilities. For example, “AB?CD” or “AB*CD”.
Select the table of choice and click OK. The table selected is added to the Selected window (see the figure below).
On the Selected Tables/Views window, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
If you clicked Change on the Selected Tables/Views window, you can select or deselect your table columns on the Table/View Columns window. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down (see the figure below).
Click Advanced to change the data type, precision/length, or scale. In general, do not change the precision/length or the scale. Once you have finished your table choices, click OK (see the figure below).
When using Prepared Statement packages, select Use fully qualified table/view names in the generated Java code.
Select the procedure required in the OTD.
In the Select Procedures and specify ResultSet and Parameter Information dialog box, click Add.
In the Select Procedures dialog box, enter the name (case-sensitive) of a Procedure or select a table from the drop-down list. Click Search. You can use Wildcard characters.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
In the Select Procedures and specify ResultSet and Parameter Information dialog box, click Edit Parameters to make changes (as needed) to the selected Procedure (see the figure below).
To restore the data type, click Restore. When you are finished, click OK.
Click Edit ResultSets to have the wizard generate the ResultSet(s) for the Oracle OTD.
Select the type of Resultset you want to generate and click Add.
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are the "By Executing", "Manually", and "With Assistance" modes.
By Executing Mode — “By Executing” mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes.
With Assistance Mode — "With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query.
Manually Mode — "Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
SELECT A, B, 3*C FROM table T |
is generated by the database. In this case, "With Assistance" mode is a better choice.
If you modify the ResultSet generated with the by the “By Executing Mode” of the Database Wizard, you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved.
On the Select Procedures and specify Resultset and Parameter Information window click Next to continue.
A Prepared Statement OTD represents a SQL statement that has been compiled. Fields in the OTD correspond to the input values that users need to provide. Prepared statements can be used to perform insert, update, delete and query operations. A prepared statement uses a question mark (?) as a place holder for input. For example: insert into EMP_TAB (Age, Name, Dept No) values (?, ?, ?)
To execute a prepared statement, set the input parameters and call executeUpdate() and specify the input values if any.
When using a Prepared Statement, the ResultsAvailable() method will always return true. Although this method is available, you should not use it with a while loop. Doing so would result in an infinite loop at runtime and will stop all of the system’s CPU. If it is used, it should only be used with the if statement.You can process a resultset by looping through the next() method.
In the Add Prepared Statements dialog box, click Add.
Enter the name of a Prepared Statement and create a SQL statement by clicking in the SQL Statement dialog box or by clicking the Statement Builder button. When you are finished creating the statement, click Save As, which gives the statement the name you just entered. This name appears as a node in the OTD (see the figure below). Click OK.
In the Add Prepared Statement dialog box, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
Click Add if you want to add additional parameters to the Statement, or highlight a row and click Remove to remove the parameter (see the following figure). Click OK.
Once you save the Prepared Statement, make sure that the ResultSet Column Name, in the Prepared Statement parameters, is a valid alpha-numeric string with no special characters (e.g. no brackets).
To edit the ResultSet Columns, click Edit ResultSet Columns (see the figure below). Although both the Name and Type are editable, Sun recommends that you do not change the Name because it can cause a loss of integrity between the ResultSet and the Database. Click OK.
The OTD Wizard fails to create OTDs with complex prepared statements that use the same column name in different tables. This problem is resolved by modifying the SQL statement to use column name aliases.
In the Add Prepared Statements dialog box, click OK.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes (see the following figure).
Click Next.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD (see the following figure).
The resulting OTD appears in the Java CAPS IDE.
The Database OTD Wizard generates OTDs by connecting to external data sources and creating corresponding Object Type Definitions. The OTD Wizard can create OTDs based on any combination of Tables and Stored Procedures or Prepared SQL Statements. Field nodes are added to the OTD based on the Tables in the external data source. Java method and parameter nodes are added to provide the appropriate JDBC functionality. For more information about the Java methods, refer to your JDBC developer’s reference.
Database OTDs are not messagable. For more information on messagable OTDs, see the Enterprise Service Bus User’s Guide.
The following steps are required to create a new OTD for the SQL Server Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the project tree, right click on the project and select Create an Object Type Definition from the shortcut menu.
From the OTD Wizard Selection window, select the SQL Server Database and click Next (see the following figure).
Enter the SQL Server database connection information in the Connection Information frame.
Required Database Connection Fields include:
Host name– the database service host name.
Port ID– the database service connection port ID/number.
Database name– the name of the SQL Server database.
User name– a valid SQL Server database username.
Password– a password for the user name noted above.
Click Next. The Select Database Objects dialog box appears
When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the .otd file.
Views are read-only and are for informational purposes only.
Click Next to continue.
In the Select Tables/Views/Aliases window, click Add (see the following figure).
In the Add Tables window, select if your selection criteria will include table data, view only data, both, and/or system tables.
From the Table/View Name drop down list, select the location of your database table and click Search (see the following figure).
Select the table of choice and click OK. The table selected is added to the Selected Tables/Views window (see the following figure).
In the Selected Tables/Views window, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
In the Table/View Columns window, you can select or deselect your table columns. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down list. If you would like to change any of the tables columns, click Change.
The data type is usually listed as Other when the driver cannot detect the data type. In these situations we recommend changing the data type to one that is more appropriate for the type of column data.
Click Advanced to change the data type, precision/length, or scale. Once you have finished your table choices, click OK. In general, you will not need to change these settings (see the figure below).
When using Prepared Statement packages, select Use fully qualified table/view names in the generated Java code.
On the Select Procedures and specify Resultset and Parameter Information window, click Add.
On the Select Procedures window, enter the name of a Procedure or select a table from the drop down list. Click Search. Wildcard characters can also be used.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
On the Select Procedures and specify Resultset and Parameter Information window click Edit Parameters to make any changes to the selected Procedure (see the following figure).
To restore the data type, click Restore. When finished, click OK.
To select how you would like the OTD to generate the nodes for the Resultset click Edit Resultsets.
Click Add to add the type of Resultset node you would like to generate.
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are "By Executing", "Manually", and "With Assistance" modes.
By Executing Mode — “By Executing” mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes.
With Assistance Mode — "With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query.
Manually Mode — "Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
SELECT A, B, 3*C FROM table T |
is generated by the database. In this case, "With Assistance" mode is a better choice.
If you modify the ResultSet generated with the by the “By Executing Mode” of the Database Wizard, you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved.
On the Select Procedures and specify Resultset and Parameter Information window click Next to continue.
Add a Prepared Statement object to your OTD.
When using a Prepared Statement, the ResultsAvailable() method will always return true. Although this method is available, you should not use it with a while loop. Doing so would result in an infinite loop at runtime and will stop all of the system’s CPU. If it is used, it should only be used with the if statement.You can process a resultset by looping through the next() method.
On the Add Prepared Statements window, click Add.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. When finished creating the statement, click Save As giving the statement a name. This name will appear as a node in the OTD. Click OK (see the following figure).
The Add Prepared Statement window displays the name you assigned to the Prepared Statement. To edit the parameters, click Edit Parameters. To change the data type, click in the Type field and select a different type from the list.
When doing a Prepared Statement with two or more tables, where multiple tables have the same column name, you must put the table name qualifier in the Prepared Statement to build the OTD.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK (see the following figure).
To edit the Resultset Columns, click Edit Resultset Columns. Both the Name and Type are editable but it is recommend you do not change the Name. Doing so will cause a loss of integrity between the Resultset and the Database. Click OK (see the following figure).
The OTD Wizard fails to create OTDs with complex prepared statements that use the same column name in different tables. This problem is resolved by modifying the SQL statement to use column name aliases.
On the Add Prepared Statements window, click OK.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes (see the following figure).
Click Next.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD. (see the following figure).
The resulting OTD appears on the Java CAPS IDE.
A single OTD can consist of many Database objects. They can be a mixture of Tables, Prepared Statements and Stored Procedures. By using the Database OTD Wizard, the OTD Edit feature allows you to:
Add or Remove Table/Views/Aliases.
Change data types by selecting a different one from a list.
Add or Remove columns from a Table object.
Add or Remove Prepared Statement objects.
Edit Prepared Statement objects.
Add or Remove Stored Procedure objects.
Edit Stored Procedure Resultsets.
When a minor change is needed for an existing OTD, there is no need to rebuild it from scratch; instead, you can edit the OTD. To edit an OTD, complete the following steps:
In the project tree, right-click on the OTD. From the submenu, click Edit (see the figure below). The Database Connection Information Wizard opens.
Connect to the database by entering the applicable information in the wizard. Once the connection is established, the Database Wizard opens, allowing you to make modifications to the OTD.
Once you have completed editing the OTD, click the Finish button to save the changes.
Once the OTD has been edited, you must verify that the changes are reflected in the Collaboration so that no errors occur at runtime. For example, if during the edit process, you delete a database object that is included in a Collaboration, the Collaboration could fail at activation or run-time.
When editing an OTD, you can connect to another instance of the database under the following conditions:
The same version of the database should be used unless the newer version is compatible with the older version.
Tables in the database must be defined with the same definition.
The stored procedures must be identical.
For tables/stored procedures built with ”qualified-name’, the schema name for the tables/stored procedures must be identical in both database instances.
The following steps are required to create a new OTD for the Sybase Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the Project tree, right click on the project and select Create an Object Type Definition from the shortcut menu.
From the OTD Wizard Selection window, select the Sybase Database and click Next. See the following figure.
Enter the Sybase database connection information in the Connection Information frame.
Host name– the database service host name.
Port ID– the database service connection port ID/number.
Database name– the name of the Sybase database.
User name– a valid Sybase database username.
Password– a password for the user name noted above.
Select the type of Sybase database objects you want included in the OTD.
When selecting Database Objects, you can select any combination of Tables, Views, Procedures, or Prepared Statements you would like to include in the .otd file. Click Next to continue. See the following figure.
Views are read-only and are for informational purposes only.
Select the types of tables or views required in the OTD.
In the Select Tables/Views/Aliases window, click Add. See the following figure.
In the Add Tables window, select if your selection criteria will include table data, view only data, both, and/or system tables.
From the Table/View Name drop down list, select the location of your database table and click Search. See the following figure.
Select the table of choice and click OK.
The table selected is added to the Selected Tables/Views window. See the following figure.
In the Selected Tables/Views/Aliases window, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
In the Table/View Columns window, you can select or deselect your table columns. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down list. If you would like to change any of the tables columns, click Change. See the following figure.
The data type is usually listed as Other when the driver cannot detect the data type. In these situations we recommend changing the data type to one that is more appropriate for the type of column data.
Click Advanced to change the data type, percision/length, or scale. Once you have finished your table choices, click OK. In general, you will not need to make any changes. See the following figure.
Select the type of stored procedures required in your OTD.
On the Select Procedures and specify Resultset and Parameter Information window, click Add.
A fully qualified Procedure Name consists of two parts: Schema Name, and the Stored Procedure Table Name. Code that is generated in a Java Collaboration Definition appears fully qualified when the Use fully-qualified procedure names in the generated Java code checkbox is selected. When this checkbox is not selected, then only the Stored Procedure Table Name appears.
On the Select Procedures window, enter the name of a Procedure or select a table from the drop down list. Click Search. Wildcard characters can also be used.
In the resulting Procedure Selection list box, select a Procedure. Click OK.
On the Select Procedures and specify Resultset and Parameter Information window click Edit Parameters to make any changes to the selected Procedure. See the following figure.
To restore the data type, click Restore. When finished, click OK.
To select how you would like the OTD to generate the nodes for the Resultset click Edit Resultsets.
Click Add to add the type of Resultset node you would like to generate.
The DBWizard provides three different ways to generate the ResultSet nodes of a Stored Procedure. They are "By Executing", "Manually", and "With Assistance" modes.
By Executing Mode |
“By Executing” mode executes the specified Stored Procedure with default values to generate the ResultSet(s). Depending on the business logic of the Stored Procedure, zero or more ResultSets can be returned from the execution. In the case that there are multiple ResultSets and "By Executing" mode does not return all ResultSets, one should use the other modes to generate the ResultSet nodes. |
|
With Assistance Mode |
"With Assistance" mode allows users to specify a query and execute it to generate the ResultSet node. To facilitate this operation, the DBWizard tries to retrieve the content of the specified Stored Procedure and display it. However, content retrieval is not supported by all types of Stored Procedures. We can roughly classify Stored Procedures into two types: SQL and external. SQL Stored Procedures are created using CREATE PROCEDURE SQL statements while external Stored Procedures are created using host languages (e.g. Java). Since external Stored Procedures do not store their execution plans in the database, content retrieval is impossible. When using "Assist" mode, highlight the execute statement up to and including the table name(s) before executing the query. |
|
Manually Mode |
"Manually" mode is the most flexible way to generate the result set nodes. It allows users to specify the node name, original column name and data type manually. One drawback of this method is that users need to know the original column names and data types. This is not always possible. For example, the column name of 3*C in this query.
is generated by the database. In this case, "With Assistance" mode is a better choice. If you modify the ResultSet generated by the “Execute” mode of the Database Wizard you need to make sure the indexes match the Stored Procedure. This assures your ResultSet indexes are preserved. |
On the Select Procedures and specify Resultset and Parameter Information window click Next to continue.
In some situations, stored procedures that uses a Select statement may not return a resultset when a conditional statement is used. In this case, no data is returned when the next() method is called, even if the resultset available() method returns “true”. This result is consistent with the type of driver we use.
When you use Insert, Update, and Delete operations, in addition to using Select, the stored procedure will return results for each operation used. We recommend invoking the enableResultSetsOnly() method if you only want to return a resultset for the Select statement.
Add a Prepared Statement object to your OTD.
On the Add Prepared Statements window, click Add.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. When finished creating the statement, click Save As giving the statement a name. This name will appear as a node in the OTD. Click OK. See the following figure.
On the Add Prepared Statement window, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK. See the following figure.
To edit Resultset Columns, click Edit Resultset Columns. The ResultSet Columns window appears. See the following figure.
Click Add to add a new ResultSet column. Both the Name and Type are editable.
Click OK to return to the Add Prepared Statements window.
When using a Prepared Statement, the ResultsAvailable() method always returns true. Although this method is available, you should not use it with a while loop since it creates an infinate loop at runtime, exhausting all CPU activity.You can process a resultset by looping through the next() method.
If the Prepared Statement is wrong, then the ResultSet Columns count is zero.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes. See the following figure.
Click Next.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD. See the following figure.
The resulting OTD appears on the Java CAPS IDE.
You can edit any database OTD you create directly from the Java CAPS IDE.
Unlock the OTD. To do this, right-click the OTD in the Project tree and select Version Control ⇒ Check Out from the menu.
The Version Control - Check Out window appears.
Select the OTD you want to check out, then click Check Out.
From the Project tree, right-click the OTD again and select Edit from the menu.
The Sybase Database Connection Information wizard appears.
Enter the connection information as described in To Connect to Database, and click Next.
Step through each of the wizard steps and click Finish to save your changes.
You must verify during project activation or at runtime that no errors are generated after editing an OTD. Errors could occur if you delete a database object that is included in a Collaboration.
The following steps are required to create a new OTD for the VSAM Adapter.
Select the type of wizard required to build an OTD in the New Object Type Definition Wizard.
On the Project tree, right click the Project and select New ⇒ Object Type Definition from the shortcut menu. The Select Wizard Type page appears, displaying the available OTD wizards.
From the New Object Type Definition Wizard window, select the VSAM Database and click Next. See Figure 1–26.
Enter the VSAM database connection information in the Connection Information frame.
Required Database Connection Fields include:
Host name– the database service host name.
Port ID– the database service connection port ID/number.
Database name– the name of the VSAM database.
User name– a valid VSAM database username.
Password– a password for the user name noted above.
Select the type of VSAM database objects you want included in the OTD.
When selecting Database Objects, you can select any combination of Tables, Views, or Prepared Statements you would like to include in the OTD file. Click Next to continue (see the following figure).
Views are read-only and are for informational purposes only.
Select the types of tables or views required in the OTD.
Aliases are not supported in the current release of the VSAM adapter.
In the Select Tables/Views/Aliases window, click Add (see the following figure).
In the Add Tables window, select if your selection criteria will include table data, view only data, both, and/or system tables.
From the Table/View Name drop down list, select the location of your database table and click Search (see the following figure).
Select the table of choice and click OK.
The table selected is added to the Selected Tables/Views/Aliases section (see the following figure).
In the Selected Tables/Views/Aliases section, review the table(s) you have selected. To make changes to the selected Table or View, click Change. If you do not wish to make any additional changes, click Next to continue.
In the Table/View Columns window, you can select or deselect your table columns. You can also change the data type for each table by highlighting the data type and selecting a different one from the drop down list. If you would like to change any of the tables columns, click Change (see the following figure).
The data type is usually listed as Other when the driver cannot detect the data type. In these situations we recommend changing the data type to one that is more appropriate for the type of column data.
Click Advanced to change the data type, percision/length, or scale. Once you have finished your table choices, click OK. In general, you will not need to make any changes (see the following figure).
Add a Prepared Statement object to your OTD.
When using a Prepared Statement, the ResultsAvailable() method will always return true. Although this method is available, you should not use it with a while loop. Doing so would result in an infinite loop at runtime and will stop all of the system's CPU. If it is used, it should only be used with the if statement.
On the Add Prepared Statements window, click Add.
Enter the name of a Prepared Statement or create a SQL statement by clicking in the SQL Statement window. If you are not logging into the VSAM database with the default user name, you must enter the Table schema name in the SQL Prepared Statement. When finished creating the statement, click Save As giving the statement a name.
This name will appear as a node in the OTD. Click OK (see the following figure).
On the Add Prepared Statement window, the name you assigned to the Prepared Statement appears. To edit the parameters, click Edit Parameters. You can change the datatype by clicking in the Type field and selecting a different type from the list.
Click Add if you want to add additional parameters to the Statement or highlight a row and click Remove to remove it. Click OK.
To edit Resultset Columns, click Edit Resultset Columns. The ResultSet Columns window appears (see the following figure).
Click Add to add a new ResultSet column. Both the Name and Type are editable.
Click OK to return to the Add Prepared Statements window.
Specify the name that your OTD will display in the Java CAPS IDE.
Enter a name for the OTD. The OTD contains the selected tables and the package name of the generated classes (see the following figure).
Click Next.
Review the selections made for the new OTD.
View the summary of the OTD. If you find you have made a mistake, click Back and correct the information.
If you are satisfied with the OTD information, click Finish to begin generating the OTD (see the following figure).
The resulting OTD appears on the Java CAPS IDE.
Placeholder