Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
cloud Frequent Contributor.
Frequent Contributor.
438 views

visual cobol db2 connect

Jump to solution

 I'm tyring to connect to AS/400 db2 and compile COBOL DB2 programs, but  I cannot find any anwser by google or your community(the link in the related quesitons' anwser all displayed "The current document displayed does not exist in the table of contents" after clicking it), can you please help? 

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Re: visual cobol db2 connect

Jump to solution

You can select TARGETDB=DB2 or you can leave it blank. This directive is only to turn on optimization for a particular database vendor, it does not actually establish the connection to the database. When using OpenESQL you use the Windows ODBC Datasource Administration tool to set up your DSN pointing to your particular iSeries ODBC driver and then you can connect to this DSN from within your program using EXEC SQL CONNECT...

The actual ODBC driver you need to get from IBM and it must be the same bitism as the program you are compiling. If you are compiling to 32-bit then you need to create your DSN using the 32-bit ODBC Datasource administrator and if you are compiling to 64-bit you need to create your DSN using the 64-bit version of this tool. On Windows 10 you can launch this from the search window by typing ODBC and selecting the correct version.

 

0 Likes
7 Replies
Micro Focus Expert
Micro Focus Expert

Re: visual cobol db2 connect

Jump to solution

Which COBOL product are you using Visual COBOL for Visual Studio, Visual COBOL for Eclipse or Visual COBOL DevHub and on what platform Windows, Linux or Unix?

To what documentation link are you referring?

Visual COBOL supports 4 methods of connecting to DB2 in order to use embedded SQL but these are dependant on what product and platform you are using. 

The DB2 ECM is used in conjunction with the embedded preprocessor from IBM and is normally used to connect to DB2 LUW. I am not rteally sure if this can be used to connect to DB2 running on the AS/400. It would be best to ask IBM about that option.

The other options involve using the Micro Focus embedded SQL preprocessor known as OpenESQL. This connects to various databases thru ODBC if you are using native code or thru ADO if using .NET code or thru JDBC if you are copmpiling to JVM byte code.

The specific drivers to use in these connections are provided by IBM and not by Micro Focus.

This is covered in the documentation here:

0 Likes
cloud Frequent Contributor.
Frequent Contributor.

Re: visual cobol db2 connect

Jump to solution
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: visual cobol db2 connect

Jump to solution

We have recently migrated our documentation to a new system. It seems as if the embedded links in the old Community posts to the old system are no longer functional.

You can find the information you are looking for here:

 

 

0 Likes
cloud Frequent Contributor.
Frequent Contributor.

Re: visual cobol db2 connect

Jump to solution

There is no option for system i database or something like that in TARGETDB of Directives in Visual COBOL-project->properties->Micro Focus->sql processor, does this mean that Visual cobol do not support DB2 on Iseries?

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: visual cobol db2 connect

Jump to solution

You can select TARGETDB=DB2 or you can leave it blank. This directive is only to turn on optimization for a particular database vendor, it does not actually establish the connection to the database. When using OpenESQL you use the Windows ODBC Datasource Administration tool to set up your DSN pointing to your particular iSeries ODBC driver and then you can connect to this DSN from within your program using EXEC SQL CONNECT...

The actual ODBC driver you need to get from IBM and it must be the same bitism as the program you are compiling. If you are compiling to 32-bit then you need to create your DSN using the 32-bit ODBC Datasource administrator and if you are compiling to 64-bit you need to create your DSN using the 64-bit version of this tool. On Windows 10 you can launch this from the search window by typing ODBC and selecting the correct version.

 

0 Likes
cloud Frequent Contributor.
Frequent Contributor.

Re: visual cobol db2 connect

Jump to solution

I connected it by using ODBC, but here comes a new problem. I can read the database but cannot update it. The SQLCODE when run the update statement in visual cobol is 0, but it is acutally not updated in DB.

0 Likes
cloud Frequent Contributor.
Frequent Contributor.

Re: visual cobol db2 connect

Jump to solution

This problem is fixed. Add a commit statement.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.