dqzg62440 2017-01-18 21:56
浏览 315
已采纳

来自Bitnami Wamp Stack的IBM i DB2访问

EDIT: It is entirely possible to do this for free This still requires a license, I'm not sure how much or exactly which license is needed as mine was bundled with my installer.

I'm trying to connect to an IBM i DB2 server from a local PC as part of a PHP application. I'm trying to set myself up for local development.

I can't find a download for "IBM DB2 Universal Database client" and/or "IBM DB2 Connect" mentioned below. Has anyone done this before and could lend some insight? I'm open to alternate solutions so long as the db2_* functions are available. I'm working with existing code with no easy/quick way to switch between connection types between development and production.

This is a near duplicate question as here but that too did not have an answer. The OP ended up giving up and connected with "IBM Client Access OLE DB" using "IBMDA400", but I also can't find a download for it. I'm not even sure if this method would enable the db2_* functions either.

  • I'm using a Bitnami Wamp stack (https://bitnami.com/stack/wamp)
  • I have downloaded the php_ibm_db2.dll from https://pecl.php.net/package/ibm_db2 and added extension=php_ibm_db2.dll to my php.ini file.
  • I've confirmed the php.ini file is the one being used by checking the output of echo phpinfo(); and successfully modifying it.
  • I've also placed php_ibm_db2.dll in the location specified by the extension_dir directive. extension_dir = "C:\Bitnami\wampstack-5.6.29-1\php\ext"

The only PHP error I see logged is when I start up the server (which is still successful - albeit no db2_* functions).

[18-Jan-2017 21:08:18 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Bitnami\wampstack-5.6.29-1\php\ext\php_ibm_db2.dll' - The specified module could not be found.

 in Unknown on line 0

[18-Jan-2017 21:08:19 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Bitnami\wampstack-5.6.29-1\php\ext\php_ibm_db2.dll' - The specified module could not be found.

 in Unknown on line 0

But the file C:\Bitnami\wampstack-5.6.29-1\php\ext\php_ibm_db2.dll does exist and has the same exact permissions as every other *.dll file in the directory (which has not been modified since the Wamp stack was installed).

I have read that "IBM DB2 Universal Database client" and "IBM DB2 Connect" must be installed on the same machine running PHP here but am having trouble finding a download for either. I can find instructions on how to install each, but no download link.

I've found a download for "IBM Data Server Client" which is behind a log in on IBM's site. I'm wondering if this is one of the two programs I need installed just by a different name. I know name consistency isn't IBM's best attribute... :D

  • 写回答

1条回答 默认 最新

  • douduidui1046 2017-02-02 13:30
    关注

    I have some answers.

    JDBC and ODBC support is free and it is typically shipped with other IBM software. This doesn't help in regards to db2_* functions in PHP. If your DB2 database is on an IBM i or even Z/OS then the only way to do this is with DB2 Connect. There are a few different versions, but for workstation development you would want DB2 Connect Enterprise Edition. The downside is the smallest number of packages they currently offer is 25 users at ~$3,800. This comes out to about $152/user but for a small shop with only 2 or 3 developers this is effectively out of the question unfortunately. At one point they did offer a 5 license package, but as of now they no longer offer it. Hopefully they will in the future.

    If your DB2 database is on LUW then all you need is IBM Data Server Client which can be downloaded for free from here (requires IBM account though): https://www-01.ibm.com/marketing/iwm/iwm/web/reg/pick.do?source=swg-idsc97&lang=en_US

    A potential alternative is to serve an API from the IBM i which is consumed by a local workstation during development of an application other than the API. However development of the API itself would still only be able to be done on the system AFAIK. You could also setup a local DB2 database as well and copy any files over. There would be further differences between production and development, but could save some money.

    Personally I think it is absurd they charge for the ability to remotely connect to the DB2 database on IBM i or Z/OS using a method other than JDBC or ODBC but charge nothing for LUW. Coupled with the fact that the smallest package is for 25 users makes it even more discouraging for small to mid-sized business (the primary customers for IBM i).

    I got this working with just "IBM Data Server Client". First I installed a Wamp stack from Bitnami, PHP 5.6.30 32bit. Then I downloaded IBM Data Server Client from the passport advantage area. I haven't tried the version from here after getting it working though, so that one might work as well. These steps are based on the version I got from passport advantage. It has an install wizard, so you can just follow the steps, but here is an IBM article on the process. That article includes installation directions for other software in addition to IBM Data Server Client, so only pay attention to the ones which apply. After installation you have to configure the client from a Window's Command prompt. To do so I followed this article. To summarize, you have to catalog the node (server) and then catalog the database. Then you restart the session and test it by connecting. Syntax is below:

    <+NODENAME+> is made up by you. <+REMOTE+> is the FQDN or IP. <+PORT+> is the port of the <+REMOTE+> you should be connecting with. Usually the port will be 446. <+database_name+> is the database name.

    db2 catalog tcpip node <NODENAME> remote <REMOTE> server <PORT>
    
    db2 catalog database <database_name> at node <NODENAME>
    
    Db2 terminate
    
    db2 connect to <database_name> user <user_name> (you will then be prompted for a password)
    

    Once this is complete you have to get the Windows PHP ddl for the IBM_DB2 driver from here. I used version 1.9.9. Then move the php_ibm_db2.dll file to your PHP extension directory as specified in the extension_dir directive in your php.ini. Then add this line to you're php.ini extension=php_ibm_db2.dll. Then restart Apache and you should be able to connect. While successfully connecting to the DB, I'm still having issues with unqualified tables at this point. It seems to use the username instead of the provided library list despite the library list being set correctly. I'll update when I figure this part out.

    This is a rough outline of what I had to do to get it working in my particular situation and not intended to be an all encompassing tutorial. If your environment is different you may have to adjust. Additionally I'm not sure if there are any other dependencies for php_ibm_db2.dll which happened to already be satisfied for me. Hopefully this will at least save someone some time and money.

    I solved the library list issue; See this answer: https://stackoverflow.com/a/43193058/967617

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败