> I have write connection to remote database (DB2) with the aid C/C++,
> but i can not install DB2 client software (everything that will be
[quoted text clipped - 10 lines]
>
> ann
What a coincidence! I just finished answering this very same question
in another forum. Hope you don't mind a "second hand" answer :-)...
A couple of solutions spring to mind:
There's the standalone DB2 CLI / ODBC driver (separate from the
clients) which is documented in the InfoCenter [1] and available from
the Application Development for DB2 page [2]. It weighs in at a
positively slim 14Mb (well ... slim compared to the sumo-wrestler that
is the standard client, anyway).
Alternatively, there is a commercial ODBC driver available from
DataDirect [3] that speaks to DB2 directly without any other software.
I've no idea how large this is (or how much it costs) since they don't
publish this on their web page.
[1]
http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb
.apdv.cli.doc/doc/c0023378.htm
[2]
http://www-306.ibm.com/software/data/db2/ad/deploy.html
[3]
http://www.datadirect.com/products/odbc/odbc-db2/index.ssp
... and here's some additional info from a followup:
> The last time I looked, the ODBC driver required a local DB2 client
> installation, cataloged databases, etc. Is there something new?
Nope, nothing "new". Just some old functionality that is very rarely
used :-)
The ODBC driver doesn't actually require the local client or cataloged
databases - it's just a lot easier to use if you happen to have them.
Even if you have the client installed, there's no requirement to
catalog a DB2 database in order to connect to it via ODBC. You can
specify all the necessary information in the ODBC connection string.
For example, see the following Python session under Windows:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbi
>>> import odbc
>>> conn = odbc.odbc('driver=IBM DB2 ODBC
DRIVER;database=MYDB;protocol=TCPIP;hostname=myserver;port=50000;uid=dav
e;pwd=XXXX')
At the time I ran the above statements, neither the node nor the
database referred to were present in my local catalog. If you don't
want to try it with Python, use a FileDSN to try it instead (the
following instructions are for Windows):
1. Fire up the ODBC Data Source Administrator
2. Switch to the FileDSN tab
3. Click on Add...
4. Select the IBM DB2 ODBC DRIVER from the list (DON'T CLICK NEXT)
5. Click on the Advanced button
6. Fill in keyword=value pairs (one per line). Obviously you should
omit the UID and PWD values here. For example:
database=MYDB
protocol=TCPIP
hostname=myserver
port=50000
currentschema=MYSCHEMA
connecttimeout=30
7. Click OK
8. Click Next >
9. Specify a filename to save the data source as
10. Click Next >
11. Click Finish
You should now be able to use the FileDSN to connect to the database
using any ODBC compliant client software (without necessarily having it
or its server in your local database or node catalog). However, while
many things claim to be "ODBC compliant", they don't necessarily "know"
about FileDSNs or work properly with them. For example, the version of
Excel I've got will quite happily open a connection with a FileDSN, but
when it tries to query anything it throws an error about not being able
to set connection attributes.
Anyway, just to prove that FileDSNs do actually work, you can refer to a
FileDSN in an ODBC connection string. For example, here's another
Python session:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbi
>>> import odbc
>>> conn = odbc.odbc('FileDSN=C:\\Program Files\\Common
Files\\ODBC\\Data Sources\\test.dsn;UID=dave;PWD=XXXX')
The fields in the connection string should be pretty obvious, but you
can find full documentation of them (and the numerous other ones that
can be specified) at:
http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb
.apdv.cli.doc/doc/r0007964.htm
Note that pretty much everything you can do with the standard client
and the catalog can be done with keywords in the connection string
(e.g. specifying the current schema, query optimization level,
filtering the list of visible schemas, setting a connection timeout,
altering the default function path, etc. etc.)
HTH,
Dave.
--