Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2005
    Posts
    3

    Unanswered: 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 11:44.

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11

    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
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    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

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  5. #5
    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

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    If I remember correctly, DB2 Personal Edition does not allow remote connections.

    Andy

  7. #7
    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

Posting Permissions

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