If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Application program in C

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-24-09, 08:24
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
Join Date: Oct 2009
Posts: 14
Question 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 !
Reply With Quote
  #2 (permalink)  
Old 12-24-09, 09:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
May be you need an Application Development Client instead?
Reply With Quote
  #3 (permalink)  
Old 12-24-09, 09:18
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
Join Date: Oct 2009
Posts: 14
Hi Nick,
What is an Application Development Client ?

The Getting Started Guide mentioned the Runtime Client though.
Reply With Quote
  #4 (permalink)  
Old 12-28-09, 01:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #5 (permalink)  
Old 12-28-09, 02:56
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 12-28-09, 06:52
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Yes, Express-C includes the Development client.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 12-29-09, 00:16
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
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 !
Reply With Quote
  #8 (permalink)  
Old 12-29-09, 02:31
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #9 (permalink)  
Old 12-29-09, 02:46
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
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
Reply With Quote
  #10 (permalink)  
Old 12-29-09, 02:47
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
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
Reply With Quote
  #11 (permalink)  
Old 12-29-09, 04:12
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #12 (permalink)  
Old 12-29-09, 07:27
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
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.
Reply With Quote
  #13 (permalink)  
Old 12-30-09, 01:05
CogitoErgoSum CogitoErgoSum is offline
Registered User
 
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 !
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On