473,787 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to connect to the DB2 on a REMOTE machine from a C++ application on Linux?

mjf
I'd like to connect from any Linux machine to the DB2 on a Linux server
via an IP adddress (or any available method that allows us to connect
to DB2 from another machine). I know we can do it in Java via JDBC in
the following fashion (suppose my IP address is xx.x.x.xxx):

sun.jdbc.odbc.J dbcOdbcDriver=c om.ibm.db2.jcc. DB2Driver
sun.jdbc.odbc.C onnectionUrl=jd bc:db2://xx.x.x.xxx:5000 0/mydb
sun.jdbc.odbc.U serId=db2inst1
sun.jdbc.odbc.P assword=mypassw d

Is there a similar way for an application in C++ on Linux? Currently
the application has to be on the same machine as the DB2 server.

I'm using DB2 UDB Express Edition V8.2 for Linux.

Thanks.

Feb 27 '06 #1
5 3571
mjf wrote:
I'd like to connect from any Linux machine to the DB2 on a Linux server
via an IP adddress (or any available method that allows us to connect
to DB2 from another machine). I know we can do it in Java via JDBC in
the following fashion (suppose my IP address is xx.x.x.xxx):

sun.jdbc.odbc.J dbcOdbcDriver=c om.ibm.db2.jcc. DB2Driver
sun.jdbc.odbc.C onnectionUrl=jd bc:db2://xx.x.x.xxx:5000 0/mydb
sun.jdbc.odbc.U serId=db2inst1
sun.jdbc.odbc.P assword=mypassw d

Is there a similar way for an application in C++ on Linux? Currently
the application has to be on the same machine as the DB2 server.


Install a DB2 client on the, well, client. Then you catalog the database on
the server at your client and go ahead happily accessing the database as if
it were a local one.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Feb 27 '06 #2
mjf
Hi Knut, thanks for the timely info! Is that the only way?

Feb 27 '06 #3
You always have to have a DB2 client installed on the client machine.
However, (and this is a little known tidbit of information) you can
skip the "catalog the database on the server at your client" step by
using a direct TCP/IP connection string with the SQLDriverConnec t()
API. We made use of this option to the ibm_db2 extension in PHP to
enable you to connect to arbitrary DB2 databases on any machine
(assuming you have the user ID and password).

/* Substitute database, hostname, port number, user ID, and password
values */
SQLCHAR *conn = "DRIVER={IB M DB2 ODBC
DRIVER};DATABAS E=myDb;HOSTNAME =hostname;PORT= 50000;PROTOCOL= TCPIP;UID=db2in st1;PWD=passwor d;";

rc = SQLDriverConnec t((SQLHDBC)conn _res->hdbc, (SQLHWND)NULL,
conn, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPR OMPT );

Dan

Feb 28 '06 #4
mjf

Dan Scott wrote:
You always have to have a DB2 client installed on the client machine.
However, (and this is a little known tidbit of information) you can
skip the "catalog the database on the server at your client" step by
using a direct TCP/IP connection string with the SQLDriverConnec t()
API. We made use of this option to the ibm_db2 extension in PHP to
enable you to connect to arbitrary DB2 databases on any machine
(assuming you have the user ID and password).

/* Substitute database, hostname, port number, user ID, and password
values */
SQLCHAR *conn = "DRIVER={IB M DB2 ODBC
DRIVER};DATABAS E=myDb;HOSTNAME =hostname;PORT= 50000;PROTOCOL= TCPIP;UID=db2in st1;PWD=passwor d;";

rc = SQLDriverConnec t((SQLHDBC)conn _res->hdbc, (SQLHWND)NULL,
conn, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPR OMPT );

Dan


Dan, thanks!!

Feb 28 '06 #5
Dan Scott wrote:
You always have to have a DB2 client installed on the client machine.
However, (and this is a little known tidbit of information) you can
skip the "catalog the database on the server at your client" step by
using a direct TCP/IP connection string with the SQLDriverConnec t()
API.


Please keep in mind that in V8 there is no AUTHENTICATION= keyword in
SQLDriverConnec t() connection string.
Consequently - for DSN-less connections AUTHENTICATION= CLIENT is assumed causing
- on Windows - a trip to domain controller and possible slowdown before
shipping connection to remote server.

Jan M. Nelken
Mar 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4612
by: Kona | last post by:
Hello, Is it right to tell that DB2 Connect has the same function that Oracle Net ? If I have an ODBC application is it also right to tell that I have 2 possibilities on my client workstation to acces a remote UDB database on a Sun machine : a) with a run-time client b) with DB2 Connect Personnal Edition Thank you
4
6475
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to define the servername / hostname in my Perl Progrem.. Here is the code:
8
2457
by: Julia | last post by:
Hi, My client uses a remote object when I host the remote object inside a windows application all seem to work fine but when I host the same object inside a windows service I get the following error " connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because
5
5093
by: smatta | last post by:
I have just installed MySql version 5.0-18 on Red Hat Fedora Core 4. It is running but I cant connect to it using MySql Query Browser running on my pc. >From my pc, I can telnet to the sql server / port. I get back a garbled message: 5.0.18-standard§}WxyuadT,☻V6F?J5i1YMT= Should this be garbled ? or is there a problem ?
2
8734
by: SB | last post by:
Hi, To connect to the DB2 Driver, from a remote machine. Do we requier DB2 client. Can't we connect by just having IBM DB2 driver which is just a single file (db2cli.dll). I am using vb application from Windows platform to connect to DB2 on Linux machine. Regards,
14
7043
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
0
4886
by: tamayi | last post by:
I have a problem (like most others posting issues on this forum :) ) I have a remote server running Windows XP SP2, with both SQL Server 2005 Express with Advanced Features and SQL 2000 installed. I can remotely connect to the SQL Server 2000 instance using Query Analyser or Enterprise Manager. I can also remotely connect to the SQLEXPRESS using Management Studio Express Edition. I am writing an ASP.NET 2.0 with VS2005 application...
1
1930
by: ganeshp | last post by:
Hi All, One programming technique to connect from one system to other is through socket programming. Socket programming can be done using programming languages like Java,C,C++. Are there any other programming techniques though which can be used to 1) Connect from local machine to remote machines AND 2) Transfer data from local machine to remote machines AND 3) Execute a process on the remote machines.
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.