Re: IBM DB2 and DSN

From: Date: Wed, 03 Jan 2001 19:12:05 +0000
Subject: Re: IBM DB2 and DSN
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-5580@lists.php.net to get a copy of this message
Well, if you're connecting to a remote machine and haven't run the "catalog" command to use that database on that node you'll run into "can't find database" problems. Using the full ODBC DSN will alleviate that. If you use just the database name, make sure you've run a "catalog node..." and "catalog database" command to let your client know where that database really lives. You are correct about the DSO causing problems - as Tyson mentioned you must compile php --with-apache=<path to apache src> and then compile apache with --add-module=src/modules/php4/libphp4.a That'll give you a nice statically linked module (which is slightly faster than a DSO anyways, but makes the binary larger.) Oh, and either run Apache as your db2inst1 user (or whomever you've setup) or make sure you get all of the exports from the db2profile/db2cshrc files and have them in the envirionment before you call odbc_connect(). If your env's not setup right, you'll get bogus SQLState error messsages (random garbage.) 'Luck! -Szii ----- Original Message ----- From: Tyson Lloyd Thwaites <tysonlt@webmedia.com.au> To: <php-db@lists.php.net> Sent: Tuesday, January 02, 2001 4:27 PM Subject: Re: [PHP-DB] IBM DB2 and DSN > You don't need to build a windows-style DSN string in this case. Just use the > name of > the database you want to connect to as the dsn, for example, to connect to the > sample db: > > $con = odbc_pconnect("sample", "db2inst1", "ibmdb2"); > > This is assuming you are connecting using PHP with DB2 support compiled in. > > In regards to apache dying, I had this problem too. You have to get the apache > source > and build PHP using --with-apache instead of --with-apxs. Then DB2 support works > fine! > > Regards, > > Tyson Lloyd Thwaites > I.T&e eCommerce Division > Adelaide > www.ite.com.au > > "Yasuhide OMORI" <omori@m-t.com> wrote in message > news:20001228174353.A1565@omori.m-t.com... > > On Thu, Dec 28, 2000 at 11:36:16AM +1030, > > Tyson Lloyd Thwaites <tysonlt@webmedia.com.au> wrote: > > > Can you please show us your code? > > > > my code is as follows: > > > > -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- > > -8<- -8<- -8<- > > <?php > > file://header("Content-Type: text/html; charset=euc-jp"); > > file://phpinfo(); > > > > file://$dsn="DRIVER=IBMdb2;SERVER=192.168.1.16;DATABASE=sample"; > > $dsn="host=192.168.1.16"; > > file://$dsn="DSN=CENTER"; > > file://$dsn="DSN=dbalias3"; > > > > file://printf("LANG: %s<BR>\n", getenv("LANG")); > > file://putenv("LANG=ja_JP.eucJP"); > > > > putenv("LANG=C"); > > putenv("LC_ALL=C"); > > putenv("LC_CTYPE=C"); > > > > $con1 = odbc_connect($dsn,"db2inst1","ibmdb2"); /* Connection object > > */ > > ?> > > -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- > > -8<- -8<- -8<- > > > > I run this php script from the client machine. > > > > On the other hand if I run the following perl script at the server it > > works well: > > > > -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- > > -8<- -8<- -8<- > > #!/usr/bin/perl > > > > use strict; > > use DBI; > > > > #my $hostname = "192.168.1.16"; > > my $db_name = "sample"; > > my $username = "db2inst1"; > > my $password = "ibmdb2"; > > > > #my $dbh = DBI->connect("dbi:DB2:" . $db_name . ":host=".$hostname > > # , $username, $password); > > my $dbh = DBI->connect("dbi:DB2:" . $db_name > > , $username, $password); > > > > my $query = "SELECT * FROM EMPLOYEE"; > > > > #printf("%s\n",$query); > > > > my $sth = $dbh->prepare($query) or die(); > > $sth->execute() or die(); > > > > while(my $ref = $sth->fetchrow_hashref()) { > > foreach (keys %$ref) { > > printf("%s: %s\n",$_,$$ref{$_}); > > } > > print "\n"; > > } > > -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- -8<- > > -8<- -8<- -8<- > > > > I tried to build php(DSO version) on the server but httpd is always > > killed by SIGTERM whenever I start apache... > > -- > > Yasuhide OMORI > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#5580) next »