Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2009
    Posts
    14

    Question Unanswered: Application program in C

    I have installed DB2 Runtime Client and yet do not see the SQL related include files. What am I missing ?

    I have gone through the DB2 Developer Handbook (IBM Redbook), 'Getting Started with Database application programming' but I am unable to find out how to obtain (if that is the right word) the include files.

    Help !

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    May be you need an Application Development Client instead?
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Oct 2009
    Posts
    14
    Hi Nick,
    What is an Application Development Client ?

    The Getting Started Guide mentioned the Runtime Client though.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    The Runtime Client allows an existing application to connect to a DB2 server. No header files are needed for that - only the libraries. If you want to develop new applications, you'll need the header files, which are part of the Application Development Client.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    Oct 2009
    Posts
    14
    Hi Stolze,
    I kind of solved that problem when I reinstalled DB2 Express-C. I was also able to compile and link successfully.

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Yes, Express-C includes the Development client.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  7. #7
    Join Date
    Oct 2009
    Posts
    14
    However, I am now getting weird message when running the code :
    Code:
    ./runtest: symbol lookup error: /opt/ibm/db2/V9.7/lib32/libdb2.so.1: undefined symbol: sqlnlsgmsg
    I gave up on C and tried in Java (JDBC Type 4 connectivity). I tried with correct JDBC URL and the connection does not happen at all. I will try to recreate and respond with proper error messages. The database is installed on my Ubuntu laptop.

    This is exasperating ! :-(

    However, with the same Java app, when I provide JDBC URL to the DB2 database of our customer's application (on AIX 64-bit), the connection happens straightaway !

  8. #8
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    I am using DB2 V9.5 on my laptop with Linux, so it may not fit exactly your situation. But I found that sqlnlsgmsg is nowhere used in any header file. There is a symbol "sqlnlsgmsg_cpcv" used in libdb2 and defined in libdb2g11n. Maybe you didn't link with the other or don't have the linker path set up correctly?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  9. #9
    Join Date
    Oct 2009
    Posts
    14
    This is my link statement
    Code:
    gcc -o runtest runtest.o -Wl,-rpath,/opt/ibm/db2/V9.7/lib32 -L/opt/ibm/db2/V9.7/lib32 -ldb2
    I "copied" it from the bldapp file in the samples folder
    Code:
    /opt/ibm/db2/V9.7/samples/c

  10. #10
    Join Date
    Oct 2009
    Posts
    14
    I copied the link step from the bldapp file in the C directory in the samples folder.

    Code:
    gcc -o runtest runtest.o -Wl,-rpath,/opt/ibm/db2/V9.7/lib32 -L/opt/ibm/db2/V9.7/lib32 -ldb2

  11. #11
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    It really depends on your platform and what you want to do. Some applications need, for example, to link with libdb2api, which is not part of the "bldapp" script.

    Another aspect is that I wouldn't use the hard-coded path to /opt/ibm/db2/... but rather $HOME/sqllib/lib. That way, you will automatically get the correct version of the libraries in case you have multiple DB2 version installed, and 32bit vs. 64bit is also resolved for you already.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  12. #12
    Join Date
    Oct 2009
    Posts
    14
    Hi Knut,
    Thanks for looking into this !

    I have uninstalled DB2 Express-C and then did a fresh install with a new instance. I am now able to connect through JDBC successfully.

    I will check the C application's connectivity later tonight and report back.

  13. #13
    Join Date
    Oct 2009
    Posts
    14
    I am now able to connect from C and JDBC successfully.

    However, with a new C program (that has cursors in it), fails pre-compiling because of undeclared host variables. I will start a new thread for this.

    Thank you, all !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •