Connecting to MySQL

Hi there,

I'm connecting to a MySQL db from Visual COBOL on Windows 10 and have a few questions I'm hoping someone can help with.

I have watched Chris Glazier's useful MF video, 'Database Access Using ODBC with Visual COBOL' .

(1) I'm assuming 32 bit throughout? I am using defaults in VC which I believe is 32 bit?

(2) When setting up my ODBC DSN I have the option of a 'unicode' MySQL 32-bit driver or an 'ansi' one. Which should I use and why?

(3) Simplest db sign-in? In our Windows production environment we have (a) standalone machines,  (b) server/client and (c) servers with users connecting with RDT. Is it easier to use built-in windows automatic security or have a specific MySQL username and password which is then specified in the programs. Simplifying deployment is my aim.

(4) In a Windows production server/client environment... is (a) the odbc driver needed on each client machine, (b) with an odbc dsn pointing from the client to the server MySQL db?

(5) Are there other MF videos you would suggest to help with Visual COBOL SQL db access. I will be using MF OpenESQL

Thank you in advance. I imagine I'll have more questions as I go!

Best wishes,

Linden

 

 

  

  • Verified Answer

    Hi Linden,

    I am glad that you found the video to be useful to you.

    The default project type for native projects is x86 which is 32-bit. This means that the ODBC DSN that you need to use must also be 32-bit. You can create this using the ODBC Datasource Administrator (32-bit) which can be found under the start menu Micro Focus Visual COBOL->Data Tools-->Data Connections group.

    The version of the ODBC driver that you use depends on the type of data you wish to access in your program, If you are storing data as Unicode characters, (2 byte characters) then you would need to use the Unicode version of the driver and access these fields using PIC N host variables. If you are using single byte ANSI characters (PC character set) only then you can use the ANSI driver and return the data into PIC X host variables.

    For OpenESQL you are required to have an ODBC driver and your DSN installed on each workstation on which the application will be running.

    There are a number of other videos in the same series as the ODBC one that you watched which cover various aspects of OpenESQL such as cursors, dynamic SQL, OpenESQL Assistant etc.

  • Thanks Chris for your full answer as always. Regards, Linden

  • Hi Chris

    Can you please make a video 'DB2 Database Access Using ODBC with Visual COBOL'?

    Thanks
  • Hi,

    Accessing DB2 through an ODBC driver is done in the same manner as other databases such as SQL Server or Oracle when using their ODBC drivers. You would use the SQL(DBMAN=ODBC) directive and set up a DSN for your DB2 driver.

    The biggest issue you would face is compatibility with existing DB2 applications that are run on the mainframe as the syntax can be different from what is provided with the OpenESQL precompiler which is based on the ANSI SQL standard.

    If you required closer compatibility to mainframe syntax then you would use the DB2 directive instead of the SQL directive and then the precompiler would interface with the IBM DB2 libraries directly instead of going through ODBC.

    I will add DB2 Database Access to my list of future videos.

    Thanks.