How to properly connect to oracle

I noticed that the standard scriptcase in our case did not want to connect to oracle. So I went looking and found me the following page:
http://downloads.scriptcase.net/downloads/v5/manual/en_us/webhelp/manual_mp/82-Tutoriais/01-oracle_oci8.htm
Yet this is sadly enough not working. So it was time to do some deep digging.
I noticed that when scriptcase is running that there is one apache httpd.exe running with a childprocess also called httpd.exe. Under this last httpd.exe there are two instances of php running. The tool I used is process explorer (use google and search for sysinternals tools).
Now I went to check on the first httpd.exe and checked the path (double click the parent httpd.exe in processexplorer en use the tab Environment). There I saw my path which was the same as the path for my normal windows aplpications.
Yet the child httpd.exe had another path namely c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\program files\scriptcase\zendserver\bin;c:\program files\scriptcase\zendserver\share\zendframework\bin;c:\program files\scriptcase\zendserver\bin
I have scriptcase installed c:\program files\scriptcase
Both the child php processes also had the same path.
So this was obviously wrong.

I have a full oracle client running (this should work with an instant client too).
And yet scriptcase would not connect with oracle. Even tho the following (demo) script would work 100% perfectly (username,password,tns name are altered here of course).

<?php
$conn=oci_connect(‘DEMOUSER’,‘DEMOPASS’,‘DEMODB’);
if (!$conn) {
$m = oci_error();
echo $m[‘message’], ’
';
exit;
}
else {
print ‘Connected to Oracle!’;
}
// Close the Oracle connection
oci_close($conn);
?>

So I will basically assume that anyone can have there instant client running and woking perfectly. If not then first get that working as it should. I personally prefer to use the FULL client since it has more tools and it basically works better.

This path thing brought one issue foreward. The path of the oracle client was NOT in de path of the httpd.exe child and not in both php instances environment paths. So obviously that was the fault. After some digging I found the error.
In the scriptcase dir soewhere you will find a ZendEnablerConf.xml mine looks like so:

<?xml version=‘1.0’ encoding=‘UTF-8’ ?>

  • <ZendEnablerConfiguration version=‘2.0’ xmlns:xsi=‘http://www.w3.org/2001/XMLSchema-instance’ xsi:noNamespaceSchemaLocation=‘ZendEnablerConf.xsd’>
  • <Global>
    <LogFile path=‘C:\Program Files\scriptcase\ZendServer\logs\ZendEnabler.log’ verbosity=‘0’ maxFileSizeKB=‘100’ />
    </Global>
  • <DefaultPool impersonation=‘true’>
  • <Environment>
    <Variable name=‘DB2INSTANCE’ value=‘DB2’ />
    <Variable name=‘PHP_FCGI_MAX_REQUESTS’ value=‘10000’ />
    <Variable name=‘TEMP’ value=‘C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp’ />
    <Variable name=‘PHPRC’ value=‘C:\Program Files\scriptcase\ZendServer\etc’ />
    <Variable name=‘PATH’ value=‘C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\scriptcase\ZendServer\bin;C:\Program Files\scriptcase\ZendServer\share\ZendFramework\bin;C:\Program Files\scriptcase\ZendServer\bin’ />
    </Environment>
    <ProcessCount start=‘2’ extra=‘8’ />
    <Timeouts connectionTimeout=‘240’ requestTimeout=‘3600’ />
    </DefaultPool>
    <ServerPool mimeType=‘application/x-httpd-php’ commandLine=‘C:\Program Files\scriptcase\ZendServer\bin\php-cgi.exe’ impersonation=‘true’ />
    </ZendEnablerConfiguration>

And there is the problem. The PATH is wrong there. A minor alteration to include the oracle client in the PATH is something that needs to be done.
So one line in the xml is changed:

<Variable name=‘PATH’ value=‘C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Oracle\10203\bin;C:\Program Files\scriptcase\ZendServer\bin;C:\Program Files\scriptcase\ZendServer\share\ZendFramework\bin;C:\Program Files\scriptcase\ZendServer\bin’ />

Since my oracle bin was on C:\Oracle\10203\bin

But that is not all that is to be done. Scriptcase has a ociw.dll and ociw32.dll delivered in the ZendServer\bin directory. These are basically wrong dll’s and they should not be used at all. The proper dll’s are already installed with the oracle client. Hence I renamed these to _oci.dll and _ociw32.dll

Next to get it to fully work the apache has to be stopped and removed and reinstalled is easy. Go to the c:\program files\scriptcase\apache2 dir (which is where my apache was) and double click the nm_stop.bat followed by the nm_uninstall.bat followed by the nm_install.bat followed by the nm_start.bat
This is needed to get the path updated in the httpd child. If you have done that then check the path using processexplorer and you will see that the oracle piece has been added to the path of the httpd child as well as the two php instances.
Since we renamed the oci’s all I then needed to do was connect…
And that worked as expected after my changes.

There is a nice tool in the apache2\bin dir called apachemonitor which is handy to autostart. It basically monitors your apache server.

So basically the page mentioned on how to connect to oracle is not fully ok, with the help of that page you wll not be able to connect to oracle. With the mentioned changes in the xml file and the renaming of the oci.dll and the ociw32.dll it will work.
(please check that they exist in the oracle client dir, those are the ones you must use and they need to exist and are normally installed there by oracle)

Re: How to properly connect to oracle

Thanks for your contribution rr. I will forward this solution to our support team.

ps: I havent been able to test it yet, so follow at your own risk.

regards,
Bernhard Bernsmann

Re: How to properly connect to oracle

I already use to with 100% success, so I know it works.

Apparently the people from scriptcase screwed it again in the last version 6.0.034 now I can not see any environment on my windows 2008 server. It would be nice if this is checked before releasing a new release. Hint: PROCESSEXPLORER from SYSINTERNALS SUITE… It allows you to show the environment of a task and also this the PATH variable…

Edit: sometimes I have my blind moments as well. I forgot to run in admin mode… That doesnt change the fact that yet again the standard install does not work properly with a real oracle client.

As a remark, the oracle instant client does NOT WORK on various oracle databases. For example a database with WE8… codepages, for that you must use the full client.