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 > Accessing db2 remotely

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-06, 10:41
dlare9 dlare9 is offline
Registered User
 
Join Date: Aug 2005
Posts: 3
Accessing db2 remotely

Hi again,

I have a DB2 database placed on a different database server (Remote) and I have C application placed on different location/pc.
I need to connect to the DB2 database from my C application.
Currently I use the ff. codes to connect to the database locally.
Code:
int ConnectToDB( struct dbConfig db ) 
{ 

	if( !strlen( db.username ) || !strlen( db.password ) ) {
		EXEC SQL CONNECT TO :dbName ; 
	} 
	else 
	{ 
		strcpy( userId, db.username ) ; 
		strcpy( password, db.password ); 
		EXEC SQL CONNECT TO :dbName user:userId using :password ; 
	} 
	SQLError( "CONNECT", SQLCODE, &sqlca ) ;
	 return( SQLCODE ) ;
}

Could somebody tell me how to do a remote connection using Embeded SQL in C and to the database w/c is on a different server.

any help would be much appreciated

Regards,
jaro


**all the sample codes that I've found in the net are all for connection locally. I can't seem to find a "connect" in this format connect(<host>, <username>, <password>);

Last edited by dlare9; 07-11-06 at 10:44.
Reply With Quote
  #2 (permalink)  
Old 07-11-06, 10:59
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
connect

local or remote - no difference
connect to db user xx using ccc
this should do in any case
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 07-11-06, 11:17
dlare9 dlare9 is offline
Registered User
 
Join Date: Aug 2005
Posts: 3
Quote:
Originally Posted by przytula_guy
local or remote - no difference
connect to db user xx using ccc
this should do in any case
I'm a little bit confuse here.
correct me if I'm wrong, you mean to say that I don't need to change any of my codes?
do I need to change some of the configuration in the DB2?


***note***
I'm using MVC6 and my OS is win2k.
My database is : DB2 Universal Database Personal Edition , Version 8.1
Reply With Quote
  #4 (permalink)  
Old 07-11-06, 22:43
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
When using the Type 2 driver, you need to catalog the remote database on your local machine and use the database alias name as the remote database is known on the local server.

If you were using the Type 4 universal driver, then you could refer directly to the remote host-name, port number, and database name.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 07-12-06, 01:32
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
connect

the last remark is for java programming and not for C language as yours.
Yes - there is no difference for local/remote database. as long as the db is known and accessible from the station where you run the program.
just : connect to dbname user uuu using ww in any case this will do
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
Reply With Quote
  #6 (permalink)  
Old 07-12-06, 08:06
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
If I remember correctly, DB2 Personal Edition does not allow remote connections.

Andy
Reply With Quote
  #7 (permalink)  
Old 07-12-06, 08:12
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
connect

could you indicate the error when connecting to remote db ?
is it a pers. edition ? as the name implies = personal = no remote connection can come in as db2 does not listen on an external port.
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
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