Issues you should be aware of
The isCOBOL SQL support based on JDBC has some differences with the IBM DB2 preprocessor. Below you find a list of the changes required to the configuration in order to obtain the same behavior between the IBM DB2 preprocessor and isCOBOL on JDBC.
Enabling the DB2 compatibility mode
For the best compatibility with the IBM DB2 rules and behaviors, you should enable the DB2 compatibility mode in the Compiler before compiling your programs with ESQL. In order to enable the DB2 compatibility mode, use the following setting in the Compiler configuration:
iscobol.compiler.esql.db2=1
When this property is set to true, the Compiler generates specific code to return the result sets in the same format that would be produced when using the IBM DB2 preprocessor. In particular, it supports the SQLDA structure and the use of date, time and timestamp as function parameters, like for example DAYOFWEEK or WEEKS_BETWEEN.
JDBC Connection
isCOBOL creates a JDBC connection. There is no need of native DB2 client libraries; you just need the IBM DB2 JDBC driver library (e.g. db2jcc4.jar.jar). You can find JDBC driver libraries at https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads.
These setup steps are required:
1. Add the IBM DB2 JDBC driver to the Classpath.
Example for Windows:
set CLASSPATH=%CLASSPATH%;\path\to\db2jcc4.jar
Example for Linux/Unix:
export CLASSPATH=$CLASSPATH:/path/to/db2jcc4.jar
2. Define the JDBC driver class in the runtime configuration:
iscobol.jdbc.driver=com.ibm.db2.jcc.DB2Driver
3. Define the connection URL in the runtime configuration. Example:
iscobol.jdbc.url=jdbc:db2://localhost:50000/SAMPLE
Different format string from DATE, TIME and TIMESTAMP
The format string used in JDBC to represent the value of DATE, TIME and TIMESTAMP columns may be different than the format string used when working with the IBM DB2 preprocessor. In order to make isCOBOL use the same format strings as the IBM DB2 preprocessor, you can set the following runtime configuration properties:
Error for NULL value fetched
When a NULL value is fetched and no indicator variable was used, you expect the error code -305.
By default isCOBOL doesn’t return errors in this case, it just sets the host variable to zero or spaces depending on the picture. In order to have the error number -305 also with isCOBOL
1. compile the program with the -csqn option,
2. add iscobol.esql.value_sqlcode_on_null=-305 to the runtime configuration.