php-db | 2001011

Re: [PHP-DB] IBM DB2 and DSN From: Yasuhide OMORI (omori <email protected>)
Date: 01/04/01

Thanx for a lot of information.
It seems that I'm in trouble before the step of PHP...

On Wed, Jan 03, 2001 at 11:12:05AM -0800,
"szii <email protected>" <szii <email protected>> wrote:
> 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.

I succeeded in creating a catalog entry but I met another problem with
code pages...

I probed on the server(192,168.1.16) as follows:

[server]$ db2 GET DATABASE MANAGER CONFIGURATION | grep -i tcp | sed 's/[^(]*(/(/'
(SVCENAME) = db2cdb2inst10
(DISCOVER_COMM) = TCPIP

(The first field has Japanese charactors. Idon't know how to use
English message catalog, because setting 'LANG=C LC_ALL=C LC_CTYPE=C'
was meaningless...)

[server]$ cat /etc/services | grep db2cdb2inst10
db2cdb2inst10 50002/tcp # Connection port for DB2 instance db2inst1

So I made up a catalog entry on the client(192.168.1.5) with the commands:

[client]$ db2 catalog tcpip node mynode remote 192.168.1.16 server 50002
[client]$ db2 catalog db sample as sample at node mynode
[client]$ db2 terminate

It seemed to work. I probed the new catalog with the following command:

[client]$ db2 list db directory

And the result was as follows:

 System Database Directory

 Number of entries in the directory = 3

Database 1 entry:

 Database alias = SAMPLE0
 Database name = SAMPLE
 Node name = MYNODE0
 Database release level = 9.00
 Comment =
 Directory entry type = Remote
 Catalog node number = -1

Database 2 entry:
...

I failed twice so I just added another entry to the catalog. If you
know how to delete an entry in the catalog please tell me. The manual
was to hard to lookup for the solution.

Anyway, Catalog node number seems strange but the others look
nice. But when I tried to connect to the server, an error occurred:

$ db2 connect to SAMPLE0 user db2inst1 using ibmdb2
SQL0332N There is no available conversion for the source code page "819" to
the target code page "954". Reason Code "1". SQLSTATE=57017

I couldn't find how to unset code page conversion or set source code
page to "954". If you know the way please tell me.

I wonder why this mismatch happened. Both machines use the same locale
'ja_JP.ujis'. It may be cause by the difference of localedata, but I'm
not sure.

PHP didn't work well ether. I just executed:

<?php
$con1 = odbc_connect("sample0","db2inst1","ibmdb2");
?>

but the result was all the same...

Warning: SQL error: , SQL state in SQLConnect in /home/omori/public_html/IBMdb2.php on line 2

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

How can I source /home/db2inst1/sqllib/db2profile or
/home/db2inst1/sqllib/db2cshrc with php? Or is there some convenient
function to use?

I added /usr/IBMdb2/V6.1/lib to /etc/ld.so.conf. Isn't it enough?

-- 
Yasuhide OMORI

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>