Created On:  23 November 2012


How do you get the DB2 JDBC JNDI database connection with Visual COBOL for Eclipse?


1. Introduction
This document covers working with OpenESQL applications under the Visual COBOL eclipse product lines, including some background on how things fit together, and an example of building and executing a sample program.
2. Software requirements
The document assumes that you already
Have a copy of Visual COBOL for Eclipse installed and licensed appropriately.
Have a copy of DB2 installed like db2 10.1 express version.
Have a copy of simple JNDI class library .jar file like simple-jndi-
3. DB2 COBOL example
   In Eclipse
   Create JVM project
   create cobol program TestDate
   Cut and paste the below program into the new program.
      $set sql(dbman=jdbc)
       program-id. TestDate as "TestDate".
       data division.
       working-storage section.
           exec sql include sqlca end-exec.
       01  hv-date pic x(10).
       01  hv-int  binary-long.
       procedure division.
           exec sql connect to sample end-exec
           exec sql
               select hiredate
               into :hv-date
               from employee
               where empno = 120
           move 999 to hv-int
           exec sql
               select days(:hv-date)
               into :hv-int
               from sysibm.sysdummy1
           display hv-date " = " hv-int " days"
           exec sql disconnect end-exec
       end program TestDate.
4. JNDI file
Create file file in c:\JavaTools\config  that contains
5. JNDI file
Create file file in c:\JavaTools  that contains
# absolute directory, using the default file protocol\\JavaTools\\config\\
# must terminate property lines with newline
6. Eclipse project JVM Build path
JavaTools as an external class folder

7. Building and executing a sample program
We simply can set a debug break point on the connect statement, choose debug configuration.

And select debug, debug perspective and use step over to get to next line.

To look in more detail you would look at sqlcode, sqlstate this is just simple example.
But hope this gets you connected.

General query