Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Using Oracle XE
#1

[eluser]alejandronanez[/eluser]
Hey everybody.

I've been trying to work with Oracle 10g XE and Code Igniter but it doesn't work... IDK what's wrong, here's the code

Code:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "1234";
$db['default']['password'] = "1234";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";

I've also tried this:

Code:
$db['default']['hostname'] = "localhost/apex";
$db['default']['hostname'] = "http://localhost/apex";
$db['default']['hostname'] = "//localhost/apex";

Also CI says this:

Quote: A Database Error Occurred

Unable to connect to your database server using the provided settings.


I need your help guys! Thanks!

Take care
#2

[eluser]Kip zonder Kop[/eluser]
Setting up a database connection to an Oracle database is more complicated then to a MySQL database. Tell us all the things you have done to realize a connection. The information you provide is not enough to get you started. Did you search the forum. If yes, what have you found and why didn't it help you. Assume the number of people with Oracle database knowledge on this forum is relatively small.
#3

[eluser]alejandronanez[/eluser]
Hey.
What I've done is:

I Installed Oracle XE and then I created a new user:

username: 12345
password: 12345

the way I enter to Oracle XE is this:

http://127.0.0.1:8080/apex or httP://localhost:8080/apex

And my /application/config/database.php is this:

Code:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "12345";
$db['default']['password'] = "12345";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

I’ve also tried this:

Code:
$db['default']['hostname'] = "localhost/apex";
or
Code:
$db['default']['hostname'] = "http://localhost/apex";
or
Code:
$db['default']['hostname'] = "//localhost/apex";

I think that's all... thank's for helping me Smile

Ps.

I created a MySQL DB and used this configuration and everything worked fine.

Code:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "test";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

When I try to work with Oracle XE CI says this:

Quote:A Database Error Occurred

Unable to connect to your database server using the provided settings.
#4

[eluser]Kip zonder Kop[/eluser]
To be honest I never tried to get Oracle to work with PHP/CodeIgniter but I do know quite a lot about Oracle and there are so many ways to specify a connection. Consequently there are many ways to get it not working. I think the information in this link might be helpful to you. (I got it from here) After you have read that you might be able to ask a more exact question.
#5

[eluser]alejandronanez[/eluser]
I solved the problem.

Here's my config file.

Code:
$active_group = "default";
$active_record = TRUE;

$tnsname = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = casa)(PORT = 1521))
            (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))';

$db['default']['hostname'] = $tnsname;
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "sid";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

That's it!

Thanks everybody, you're a great community!
#6

[eluser]phenom[/eluser]
i've got a problem about the connection to oracle

i write this in the database.php
Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost/XE";
$db['default']['username'] = "1234";
$db['default']['password'] = "1234";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

then i register it to autoload.php

when i run it, it gives me an error message :
Quote:An Error Was Encountered

Your database.php file does not appear to contain a valid configuration array.

and i've do what you write but still got the same error

:down:
#7

[eluser]phenom[/eluser]
[quote author="phenom" date="1263920618"]i've got a problem about the connection to oracle

i write this in the database.php
Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost/XE";
$db['default']['username'] = "1234";
$db['default']['password'] = "1234";
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

then i register it to autoload.php

when i run it, it gives me an error message :
Quote:An Error Was Encountered

Your database.php file does not appear to contain a valid configuration array.

and i've do what you write but still got the same error

:down:[/quote]

I've solved the problem
i did wrong in autoload.php
i load the database in config <-- bad mistake :red:
it should be in the libraries
#8

[eluser]Unknown[/eluser]
in this link,you have to do this..

object(CI_DB_oci8_result)#17 (9) {
["stmt_id"]=>
resource(33) of type (oci8 statement)
["curs_id"]=>
NULL
["limit_used"]=>
NULL
["conn_id"]=>
resource(24) of type (oci8 persistent connection)
["result_id"]=>
bool(true)
["result_array"]=>
array(1) {
[0]=>
array(3) {
["USERNAME"]=>
string(8) "username"
["PASSWORD"]=>
string(32) "..."
["FLAGS"]=>
string(1) "0"
}
}
["result_object"]=>
array(0) {
}
["current_row"]=>
int(0)
["num_rows"]=>
int(1)
}

can u help me,how i'm supposed to use this code?thanks
#9

[eluser]Unknown[/eluser]
Hi,
I used the following way and it works
we must write the code in -- system/application/config/database.php

$active_group = "default";
$active_record = TRUE;

$dbhost = "172.18.3.226"; //host
$dbport= "1521"; //port default is 1521
$dbname = "testing"; //name of database
$dbuser = "testuser"; //db user with all priviliges
$dbpassword = "testuser"; // password of user
$dbConnString = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = ". $dbhost .")(PORT = ". $dbport ."))
)(CONNECT_DATA =(SERVICE_NAME = ". $dbname .")))"; // connection string for this we must create TNS entry for Oracle

$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = $dbuser;
$db['default']['password'] = $dbpassword;
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";


--
Shrikant Kinhikar
#10

[eluser]Siregar[/eluser]
i want to ask about my config error.
i have try many configuration example :
Code:
$dbhost = "178.178.2.82";    //host
$dbport= "1521";          //port default is 1521
$dbname = "DBMD";        //name of database  
$dbuser = "usermd";      //db user with all priviliges
$dbpassword = "honda";    // password of user
$dbConnString = "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = ". $dbhost .")(PORT = ". $dbport ."))
  )(CONNECT_DATA =(SERVICE_NAME = ". $dbname .")))";  
$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = $dbuser;
$db['default']['password'] = $dbpassword;
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';

and like this,
Code:
$db['default']['hostname'] = '//178.178.2.82:1521/DBMD';
$db['default']['username'] = 'usermd';
$db['default']['password'] = 'honda';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';

but i get error like this,

Quote:A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: D:\Siregar\Study\Sem IV\IBAD\KP\CodeIgniter_2.0.2\system\database\DB_driver.php

Line Number: 124

as additional info, i use oracle 6i and oci8.dll from oracle 10g in my xampp/apache/bin.
How to solve this problem, thank you in advance.




Theme © iAndrew 2016 - Forum software by © MyBB