On PECL, there is the latest Windows DLL in version 1.3.3. Unfortunately, they didn't provide one for version 1.3.4. I'd like to get the DLL from some reputable source. Otherwise I'll have to compile it from sources myself in which case some hint as to what should be taken care of would be much appreciated.
PHP 5.6 – Availability of Windows DLL for PDO_IBM Driver
db2db2-luwPHPwindows
Related Solutions
For most databases including Data Warehouses Read Committed is a sufficient isolation level. I wouldn't use Read Uncommitted due to the possibility of incorrect answers. On SQL Server we can also add Read Committed Snapshot Isolation. This versions rows and avoids queries being blocked by updates. Don't know if you have something similar on DB2.
Creating a new instance
The following command line call will create a new database + instance
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName sid -sysPassword pass -systemPassword pass
because I have a dedicated oracle user for my install I also had to use -serviceUserPassword. With regards to the passwords, despite being in silent mode if you miss these out, then you will be prompted for them rather than the program failing so while technically the minimum is
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName sid
you wont be able to script that - the program will just hang indefinitely.
this command's usage is slightly mysterious and if you get it wrong it provides the amazingly useful message:
'Not all required options provided for the command "createDatabase".Please refer to the manual for details.'
Thankfully if you trawl through the reams and reams of online documentation eventually you can find what information it needs here along with what all the options are and what they are for.
A further thing I found here is that it can fail but it doesnt tell you from the command prompt - you should check the log files that it makes (it will tell you where these go). Just because it says 100% complete doesnt mean it has actually worked! You could just have got 100% of the way to failure! In particular if it finishes very quickly then this is a warning sign - expect it to take at least a couple of minutes. I found I needed to run this as administrator the second time around - I suspect this is always the case but on the first run the UAC was disabled.
Starting the listener
This bit is once per-server, so doesnt need scripting for my needs. I thought it was worth mentioning though as a few more things were required to make my instance usable from other machines.
I found that after doing the above I couldnt connect to the database remotely but could from sqlplus locally. In someways this local access was a false positive as it turned out there was no listener running on the server (probably because of the software only install). You can determine if this is the case by looking to see if TNSLSNR.exe is running on the server.
Thankfully starting the listener is easy if it isnt already running. You use a command line program called lsnrctl. This is probably the nicest oracle command line program I've used. It tells you how to use it and just worked without any messing about. You can just use it interactively and type 'start' when it comes up.
Note you may need to run the above from an administrator shell If you see something like the following:
LSNRCTL> start
Starting tnslsnr: please wait...
Unable to OpenSCManager: err=5
TNS-12560: TNS:protocol adapter error
TNS-00530: Protocol adapter error
then try doing it as admin.
Automatic registration
After it started I still couldnt connect to the database externally. You can use lsnrctl status to determine if the listener knows about the database instance. If you get a message somewhere in the output that says
The listener supports no services
then it isnt working. I wanted to use automatic registration because it sounded like the way to go and it turned out from a bit of reading, that instances register with listeners when they start.
To restart an instance you do the following (docs here):
Use the sqlplus command line. You will need to login as a user with SYSDBA priveledges (eg system) syntax:
sqlplus name/pass as SYSDBA
then run 'shutdown' and wait for it to finish. then run 'startup' and wait for it to finish.
There is a good post here that also suggests another way of doing it
note if you haven't got a tnsnames.ora file you will need to specify the host in the connection string - this wont work:
sqlplus name/pass@serviceName
do this instead:
sqlplus name/pass@//localhost/serviceName
Hey presto you should have your instance registered with the listener. You can verify this by running lsnrctl status again.
You should see something like this:
Service "horse" has 1 instance(s).
Instance "horse", status READY, has 1 handler(s) for this service...
Opening a firewall port
The final step in making the instances on the server accessible is to open a port on your firewall. You can determine the port you need to open from the lsnrctl status message - there should be a section that looks like this:
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))
1521 is the default port if you don't have a listener.ora file as mentioned here
To open a port on the firewall on our windows 7 server I used the following instructions.
After doing all of the above I could connect to the instance from my local machine. Sucess! Hopefully deploying more instances is just going to involve repeating the dbca command. Since the listener will already be up it should just register with it immediately. I'll try this out and post any further complications.
Related Question
- Mysql – Aborted connection (Got an error reading communication packets) MySQL on Amazon RDS
- Postgresql – Problems while building plpgsql_check on Windows
- IBM DB2 PHP Client – How to Configure IBM DB2 Client for PHP
- Db2 – set the I/O size for DB2 9.7 LUW driver (AIX 6.1)
- Windows ODBC Driver versions for Netezza
- PHP – Does a PHP 7.3 Cassandra Driver Exist?
- Postgresql – How am I supposed to update PostgreSQL on Windows, once installed, without manually installing new installers
Best Answer
We solved this problem by using non-object-oriented extension ibm_db2. Fortunately, our code wasn't using many calls or special features so we were able to refactor our code quite quickly, e.g. from:
to: