IBM i DB2 access from Bitnami Wamp Stack - php

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

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

Related

DB2 ODBC Connection with PHP in Linux

This has become a frustrating thing for me and I'm reaching out to you guys after two days of unsuccessful attempts.
I need to make odbc connection to DB2 through php, but here's my issue:
I have installed unixODBC and php-odbc. Where can I find iSeriesAccess-6.1.0-1.2.i386.rpm
I have searched everywhere on IBM website without success.
I really appreciate it if someone could give me a link to download this rpm file.
IBM Access (the product containing the ODBC driver) is licensed software and is only available through ESS:
This optional package, IBM i Access Client Solutions - Linux Application Package, is only available for download on the Entitled Software Support (ESS) website under 5761-SS1 or 5770-SS1. Physical media is not available. Here is an example of downloading IBM i Access Client Solutions along with its two optional packages (Linux Application Package and Windows Application Package).
Obtaining Access Client Solutions
IBM i Access is not free software. There's an IBM Technote explaining how to obtain the software. In short, you need to log in to the IBM ESS (Entitled Software Support) site at the following URL: http://www-304.ibm.com/servers/eserver/ess/index.wss
My company uses IBM i Access, however, the files had to be downloaded via the company that set up our server. They had access in ESS to download the drivers, whereas the account that we had in-house didn't. I guess that means the license is theirs and not ours.

Connect to a remote Windows Sybase database from Ubuntu via PHP

Ubuntu 12.04 LTS Precise
I'm trying to use PHP to connect to a remote Windows Sybase database. Let us assume Windows 7 Enterprise SP1. I'm currently doing this in PHP:
$db = sybase_connect("10.1.208.111", "$user", "$pass");
And I'm getting an error of:
Warning: sybase_connect(): Unable to connect to server: 10.1.208.111
I understand that the server I'm connecting to (10.1.208.111), needs to be in the interfaces file. I'm trying to figure out where that is, or even if I have one on the Ubuntu server (I'm still new to linux itself). I read that the path for the file is located in the SYBASE environmental variable. I don't know where that is either. Can anyone shed some light? I can offer more information if you need it, I just don't know what you need right off the bat.
PS: The windows machine has Micros RES installed on it. That's the database I'm trying to pull data from. Not sure if that matters.
The default installation directory for Sybase ASE in windows is C:\sybase, so your interfaces (interfaces.ini) should be located there.
For SQL Anywhere, the interfaces file is called SQL.ini, and it's location varies, but you should be able to do a search of your system drive to find it.
For SQL Anywhere you probably want to use the PHP apis that are provide by SAP Sybase. The SQL Anywhere documentation is a pretty good place to start, as it covers all the pieces that need to be installed to get SQL Anywhere to talk to PHP.
SQL Anywhere 11: SQL Anwhere PHP API
You may also be able to find good information over at the SAP Community Network site for SQL Anywhere.

php pdo_informix on windows 7 64 bit and wamp 64 bit

I try to install pdo_informix in WAMP 64 bit on windows 7 64 bit, but I found problem because pdo_informix.dll is version 32 bit. I try to search for pdo_informix.dll, but I can't found it. How to solve this problem?
Thank you for help.
It looks as though you may have to download the source for PDO Informix and compile it; that is always an available option for open source (get the code and compile it) but it presumes you have the facilities needed to compile code.
A Google search with the terms 'pdo informix 64-bit windows' picks up this question, amongst others, and also points to the PDO Informix manual which includes links to 'how to compile PDO extensions' etc.
Google also lists a IIS forum posting on the subject which says (lightly edited):
As an alternative, there is a simpler option; however, it may not be ideal depending on your requirements. There is a tool called OpenAdmin Tool for Informix. This is a PHP-based tool for administrative tasks on an Informix database. The tool is a ready-built Apache webserver with PHP set up which uses the Informix pdo driver (it is actually embedded), however, the rest of it is the same, you could copy any extra extensions/modules from your existing setup over to the OpenAdmin PHP directory and enable them in the OpenAdmin php.ini file.Then put whatever ever resides in your existing htdocs folder into the OpenAdmin htdocs folder.
It lists links to the IBM site for OAT (OpenAdmin Tool), but the links embed the date 2006-01-26, so they're probably not current and likely not directly available. The latest information is available from the OpenAdmin Tool website.
OAT does not seem to be distributed for 64-bit Windows specifically.
I also have the same problem right now.
The OpenAdmin Tool website says that the Informix Client SDK which is available on the IBM website includes a ready-to-use OpenAdmin Tool including Apache Webserver, PHP and the pdo_informix extension.
However, the current SDK 4.10 is NOT shipped with the OpenAdmin Tool.
So you have to set up your own environment with Apache and PHP and the community edition of OpenAdmin Tool. I tried Apache 2.4 for x_86 and x_64 Systems (Windows) and all available Versions of PHP (5.4, 5.5, 5.6).
You can download the pdo_informix extension for PHP 5.4 here:
https://pecl.php.net/package/PDO_INFORMIX/1.3.1/windows
And there was a guy who compiled it for PHP 5.5:
https://github.com/maryo/php-5.5-windows-extensions/tree/master/php_pdo_informix-1.3.1-5.5-vc11-x86
There is also a hint that it is very important to set the INFORMIXDIR environment variable correctly. I tried several possibilities such as C:\Program Files\IBM Informix Software Bundle\ or with a trailing \bin but it did not help.
Unfortunately, nothing worked for me. The pdo_informix extension did not load. Hopefully I can help someone with my explanations to get the OAT up and running.

php odbc_connect to mssql works in linux/ubuntu command line not browser

I really feel like I have done an exhaustive search on this matter, found similar issues and have tried a number of things without success, so I am for the first time posting a question here:
I do a lot of web pages/web programming (PHP/jQuery mostly) and host these pages on my digital library department's Drupal/Ubuntu Server. I just code them and post them via Dreamweaver, as I don't have much use for the Drupal front end. I just need the server for my pages.
Anyway, I am wanting to make some PHP pages that can connect to our library catalog, so I have been working from the command line of the Drupal/Ubuntu server. I installed unixODBC, had some troubles, installed FreeTDS, set up the drivers and the DSN.
Finally...
I was able to get a connection to our catalog via tsql and run a query.
I made a basic PHP script to test the connection:
It works from the Ubuntu command line of the server (connection successful).
It doesn't work when I load it in a browser. I get the dreaded:
Warning: odbc_pconnect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/mydirectory/mytestpage.php on line 15
UPDATE: I installed a test Ubuntu Server in a partition on my laptop, where I started clean, installed Apache2/PHP5(with mssql and odbc modules, etc)/FreeTDS, etc. I got a tsql connection. I made the basic PHP script and ran it successfully from the command line. Then I navigated to the php page from a browser and it worked! I still need to get this to happen on the Drupal server version, but now I have at least narrowed down the issue to something on the Drupal server.
I searched and found such possible causes as:
File permissions, which I think I got corrected, but no go
That maybe I had set up a User DNS and not a System DNS which I tried my best to correct with the proper "odbcinst" command options
That maybe php needs to be running in CGI mode instead of as a module. But that seemed unlikely from what I read. And I am not sure how that would affect Drupal. (There are limits to the system wide changes I should make here.)
A number of people said it was SElinux blocking Apache from displaying the page in the browser, but temporarily disabling SElinux didn't work.
Thanks for any assistance!
Check you have enabled the mssql.so etc at the following location
/etc/php5/apache2/php.ini, you will be having another at /etc/php5/cli/php.ini
in ubuntu php.ini will be maintained separately for cli & mod_php apache configuration
If you are going to test your odbc sources on the commandline, I would advise you use the isql utility instead of tsql. isql uses the DSN you defined in odbc.ini to connect to the database, while tsql connects directly to your database.
If it works with isql, it should work on your webpage as well.
Also check the Drupal/Ubuntu Server files /etc/odbc.ini (your DSN sources) and /etc/odbcinst.ini (TDS Driver settings) to see if they match the ones on the working Ubuntu installation.
My guess is it has something to do with the php. ini file. On my Ubuntu system I've got 2.
One in /etc/php5/apache2/php.ini
And one in /etc/php5/cgi/php.ini
The values in the apache2 path will need to be adjusted to allow the connection. Unfortunately outside of that I'm not too much use as I use MySQL and Mongo
Copy your php.ini from work server to non-work server, add make needed environment variables accessible before starting your web server, and make sure your web-server has full access to your odbc and odbcinst ini-files. And so, using mssql knowledge base or help.

Enable MsSQL PDO driver on LAMP w/ PHP5.3.6

I've been googling and searching SO for the better part of an hour, and fail to find a good answer. I'm a server admin noob here, so I'm sure this is not too difficult, but I sure don't know what to do.
Info:
Running PHP5.3.6 on an Apache server, using WHM/cPanel as the server admin GUI
I'm trying to connect to a client's MsSQL database, and alas, get the following error:
Fatal error: Call to undefined function mssql_connect()
So I start googling, see that perhaps that's not the best function to use anyway. Alright, so I look at PHPinfo for PDO support:
PDO drivers sqlite, sqlite2, mysql
How on earth do I get mssql to show up in that list, so I can do something like the following:
$dbh = new PDO("mssql:host=host.name;dbname=name", 'user', 'pass');
I can't seem to google my way out of this one. Any thoughts?
You can uncomment the "extension=php_pdo_mssql.dll" line in php.ini if you have access to it.
If it still doesn't work, you might want to try this (once again, only if you have access to it):
ntwdblib.dll - The most common issue is that you do not have the
ntwdblib.dll file installed in your PHP directory (where php.exe is,
or sometimes placing it in the ext directory works as well). This
library can be found with your Enterprise Manager dll's or in your SQL
servers system32 folder. It's generally best to take the file from the
server where SQL Server is installed -quoted from
http://www.helpspot.com/helpdesk/index.php?pg=kb.page&id=13
If you are doing this on some kind of rented hosting (IE: Shared Hosting) you may need to contact the support from the hosting provider to get them to enable it if you can't get it to work.
http://us.php.net/mssql also has a lot of information. The installation is what I just stated above, but the user comments address a lot of more unique situations and provide more detail.

Categories