<div class="post-text" itemprop="text">
<p>The problem is, i have an application that the client demands it runs under Oracle DB.</p>
<p>I already have Client 11c installed, as well as Oracle Database.</p>
<p>My PHP was built using the following configuration:</p>
<pre><code>"--with-pdo-oci=c:\php-snap-build\deps_aux\oracle\x64\instantclient_12_1\sdk,shared"
</code></pre>
<p>So i copied the instant client to this folder, and put it in the system path as well.</p>
<p>Still i'm getting:</p>
<pre><code>PS C:\php&gt; php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_oci' (tried: ./ext\pdo_oci (The specified module could not be found.), ./ext\php_pdo_oci.dll (%1 is not a valid Win32 application.)) in Unknown on line 0
</code></pre>
<p>When trying to run php -m with display_startup_errors = on</p>
<p>I've tried download other PHP Binaries and looked up on every possible corner of the internet.</p>
<p>Can anyone help me solve this?</p>
<p>P.S. PDO is a must.</p>
<p>Thanks in advance!</p>
</div>

<div class="post-text" itemprop="text">
<p>I have two machines:</p>
<ol>
<li>Windows 7 x64</li>
<li>Windows server 2012 R2 x64</li>
</ol>
<p>In the first machine I installed:</p>
<ul>
<li>Apache 2.4 TS VC11</li>
<li>PHP 5.6.19 TS VCC</li>
<li><a href="http://windows.php.net/downloads/pecl/releases/oci8/2.0.8/" rel="nofollow">php_oci8-2.0.8-5.6-ts-vc11-x64</a></li>
</ul>
<p>I connect to local/remote oracle databases without problem. </p>
<p>The second machine is a fresh server installation, it does not have local oracle dabatases, nothing. The idea is to connect to a remote oracle instace. So I made the same installation (apache and php with same versions as first machine), but the first error I found was that the oci8_11g extension is not loaded. My question is, do I need to install some "driver" or "client" for oracle in this server? The apache instance and php work as expected except with error mentioned.</p>
</div>

<div class="post-text" itemprop="text">
<p>I am trying to connect to Oracle database which is not on my PC. I have installed Xampp, PHP and Oracle instant Client. I have added a windows environmental path to C:\instantclient_11_1. The Oci8 is enabled too when I check from phpinfo(). I have added the extension extension_dir = C:\php-5.4.0\ext to the php.ini and also enabled extension=php_oci8_11g.dll. Then when I try to connect to the database using the code below:</p>
<pre><code> &lt;?php
$conn = oci_connect('username', 'password');
$query = 'select table_name from user_tables';
?&gt;
</code></pre>
<p>It says Warning: oci_connect(): ORA-12560: TNS:protocol adapter error. Could anyone help?</p>
</div>

<div class="post-text" itemprop="text">
<p>I need to connect oracle 11g database with my xampp server and I need both local and remote connection. For that what I did is first I installed the oracle 11g express edition and the downloaded the <code>instantclient-basic-nt-11.2.0.4.0</code> and placed the extracted folder <code>instantclient_11_2</code> in <code>C:\</code> then I set the environment variable (system variables) and my path value looks like this <code>path=C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\instantclient_11_2</code>.</p>
<p>Then I removed the <code>;</code> before <code>extension=php_oci8.dll</code> and <code>extension=php_oci8_11g.dll</code> from the <code>php.ini</code> file. Then first I tried to connect with my local database:</p>
<pre><code>$tns_turjo = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.13)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))'; // tns of another pc
$tns_ishrak = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.18)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))'; // tns of my pc
$conn = oci_connect('system', 'cibl123*#', $tns_turjo);
if($conn) {
echo "connected";
}
else {
echo "not";
}
</code></pre>
<p>When I pass <code>$tns_ishrak</code> it echoes <code>connected</code> but when I try to access the oracle database of another pc i.e. use the <code>$tns_turjo</code> then it echoes <code>not</code> and the error is </p>
<pre><code>Message: oci_connect(): ORA-12170: TNS:Connect timeout occurred
</code></pre>
<p>I have also changed the username and password while connecting to another pc.</p>
<p>N.B. After enabling the .dll extensions from the php.ini file whenever I start the Apache I get a pop up warning in xampp which is <code>Module 'oci8' is already loaded</code> </p>
<p>How can I solve the remote connection issue?</p>
</div>

<div class="post-text" itemprop="text">
<p>I'm developing a website in PHP that interacts with Oracle10g remote server database. I've googled on this topic a lot and couldn't find a solution, though i got some idea on tnsnames.ora file. I've installed WAMP in my machine. What are steps to connect to Oracle remote database?? Can any one explain it step by step??
I created a site which connects to MySQL datebase a year ago which wasn't this much tough.</p>
<pre><code>$con = oci_connect('username', 'password', '//server ip:port/service name');
</code></pre>
<p>It's throwing "Call to undefined function oci_connect()" error.</p>
</div>

<div class="post-text" itemprop="text">
<p>I've searched everywhere in google for a solution but I'm still unable to connect to oracle using PHP.</p>
<p>I have the following in my php file</p>
<pre><code>$conn = oci_connect("username","password", "sid");
</code></pre>
<p>However, when ever I try and access the php page, I am getting the same error </p>
<pre><code>Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\consult.php on line 5.
</code></pre>
<p>In XAMPP folders I've looked at the php.ini file and removed the leading semicolon so that I'm left with <code>extension=php_oci8_11g.dll</code>.</p>
<p>I restarted XAMPP, and I'm getting oci8.dll doesn't exist. I then downloaded oracle instant client but I'm slightly confused as to which folder it is supposed to be placed in.</p>
</div>

<div class="post-text" itemprop="text">
<p>I want to run multiple sql queries in a single database connection using oracle 10g and php. Here for every sql query queries I have to create database connection. Is there any way to run multiple sql queries in a single database connection or we have to fetch data this way only? Because when we have to run 50 queries, we have to write 50 times like below. </p>
<pre><code>&lt;?php
include("mydb.php");
// run query
$sql6 = "select * from dat where to_char(WD,'dd/mm')='19/08'";
$stid6=oci_parse($conn, $sql6);
// set array
$arr6 = array();
if(!$stid6){
$e=oci_error($conn);
trigger_error(htmlentities($e[message],ENT_QUOTES),E_USER_ERROR);
}
$r6=oci_execute($stid6);
if(!$r6){
$e=oci_error($stid6);
trigger_error(htmlentities($e[message],ENT_QUOTES),E_USER_ERROR);
}
// look through query
while($row = oci_fetch_array($stid6,OCI_ASSOC)){
// add each row returned into an array
$arr6[] = array(($row['WD']) , (float)$row['DATA']);
}
oci_free_statement($stid6);
oci_close($conn);
?&gt;
&lt;?php
include("mydb.php");
// run query
$sql7 = "select * from dat where to_char(WD,'dd/mm')='11/03'";
$stid7 = oci_parse($conn, $sql7);
// set array
$arr7 = array();
if(!$stid7){
$e=oci_error($conn);
trigger_error(htmlentities($e[message],ENT_QUOTES),E_USER_ERROR);
}
$r7=oci_execute($stid7);
if(!$r7){
$e=oci_error($stid7);
trigger_error(htmlentities($e[message],ENT_QUOTES),E_USER_ERROR);
}
// look through query
while($row = oci_fetch_array($stid7,OCI_ASSOC)){
// add each row returned into an array
$arr7[] = array(($row['WD'])) , (float)$row['DATA']);
}
oci_free_statement($stid7);
oci_close($conn);
?&gt;
................
................
</code></pre>
<p>*Pardon me, I forgot to mention that we have store day-wise data in different array. I mean to say that 11/03's data will store in arr1 and 19/08's data will be stored in arr2. Not in same array.</p>
</div>

我win7 64位系统，jdk是64位的1.7版本，oracle装的是32的10g，客户端跟服务器端都装了
，我在用jdbc:oracle:oci方式连接数据库时连接失败，而用jdbc:oracle:thin方式就行，错误如下：
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.UnsatisfiedLinkError: E:\Ebook\JavaSE\develop\Oracle\product\10.2.0\client_1\BIN\ocijdbc10.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
... 24 more
Caused by: java.lang.UnsatisfiedLinkError: E:\Ebook\JavaSE\develop\Oracle\product\10.2.0\client_1\BIN\ocijdbc10.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3135)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3131)
at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:221)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:132)
at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:78)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseProductName(VendorDatabaseIdProvider.java:76)
at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseName(VendorDatabaseIdProvider.java:61)
at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseId(VendorDatabaseIdProvider.java:49)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:395)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:295)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 37 more
这个有什么解决办法吗

<div class="post-text" itemprop="text">
<p>This is on Oracle 8i (sorry, no control over this) and PHP 7.</p>
<p>I am building a search tool. It's a simple form with 3 fields, using HTTP Post method. PHP then does some checks on the 3 fields' values, determines if they are valid and then sends the values off to the SQL query. The query looks something like this; remember its 8i so no ANSI join here :</p>
<pre><code>SELECT
reports_table.*, documents_table.*, cases_table.*
FROM
reports_table, documents_table, cases_table
WHERE
reports_table.report_id = documents_table.report_id
AND reports_table.report_id = cases_table.report_id(+)
-- Report Number filtering
AND reports_table.report_no =
CASE
WHEN $report_no_isvalid = 1
THEN '$report_no' -- Oracle expects datatype varchar2
ELSE reports_table.report_no
END
-- Document Number filtering
AND documents_table.document_no =
CASE
WHEN $doc_no_isvalid = 1
THEN $doc_no -- Oracle expects datatype number
ELSE documents_table.document_no
END
-- Case Number filtering
AND cases_table.case_no =
CASE
WHEN $case_no_isvalid = 1
THEN '$case_no' -- Oracle expects datatype varchar2
ELSE cases_table.case_no
END
</code></pre>
<p>The user is required to enter at least a Report Number, or a Case Number. The full numbers are required, i.e. no wildcard search is allowed.
The <code>reports_table</code> is very large.
When searching by Report Number, the database takes a very long time as if the CASE evaluation that acts on the validity of the Report Number, i.e. this section of code here</p>
<pre><code>AND reports_table.report_no =
CASE
WHEN $report_no_isvalid = 1
THEN '$report_no' -- Oracle expects datatype varchar2
ELSE reports_table.report_no
END
</code></pre>
<p>is being evaluated after the joining operation. It seems to be indeed evaluated though, because if I add another simple predicate in the WHERE clause to limit the scope on the Report Number, the database answers very fast, with the expected result. e.g. lets say the Report Number I'm searching for is 'R123456', if I add <code>AND reports_table.report_no LIKE 'R1234%'</code>, as a predicate outside of the CASE statement, the performance is good. Otherwise it is extremely slow, as if Oracle is scanning the whole <code>reports_table</code> in trying to make the join.</p>
<p>I would like to find a way to tell Oracle to ensure its looking at the conditional CASE filter on the Report Number when performing the join but I have no idea how.
Or maybe I should avoid altogether that kind of conditional restriction on the join, and if so, what technique could I use to achieve what I'm trying to do?</p>
</div>