# Rails + Oracle

**URL:** <https://www.ruby-forum.com/t/rails-oracle/99987>\
**Category:** Ruby\
**Created:** [February 1, 2006, 11:25pm UTC](https://www.ruby-forum.com/t/rails-oracle/99987 "2006-02-01T23:25:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 1, 2006, 11:25pm UTC](https://www.ruby-forum.com/t/rails-oracle/99987/1 "2006-02-01T23:25:06Z")

</div>

I have tried every connection string on the Rails site and it will not  
connect. I can create a regular dbi script and connect and pull out  
data.

If someone is using Rails + Oracle can you post the relevent portions  
of your connection string? Please?!

Robert

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 2, 2006, 1:30am UTC](https://www.ruby-forum.com/t/rails-oracle/99987/2 "2006-02-02T01:30:34Z")

</div>

Robert H. wrote:

> I have tried every connection string on the Rails site and it will not  
> connect. I can create a regular dbi script and connect and pull out  
> data.
> 
> If someone is using Rails + Oracle can you post the relevent portions  
> of your connection string? Please?!

Not sure what you’re looking for. If you can connect to the database  
using sqlplus:

```
$ sqlplus user/pass@dbhost

```

then the following database.yml entry should work for you:

development:  
adapter: oci  
host: dbhost  
username: user  
password: pass

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 4, 2006, 4:25am UTC](https://www.ruby-forum.com/t/rails-oracle/99987/3 "2006-02-04T04:25:37Z")

</div>

I will try those but I believe I already have to no avail. I will try  
and see.

Robert

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 4, 2006, 4:34am UTC](https://www.ruby-forum.com/t/rails-oracle/99987/4 "2006-02-04T04:34:43Z")

</div>

On 2/3/06, Robert H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I will try those but I believe I already have to no avail. I will try  
> and see.

If all else fails, strip the newlines from a full TNSNAMES.ORA entry,  
and put it on the host line.  
I’ve had to do that on crazy instantclient servers in the past.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 2, 2006, 7:38pm UTC](https://www.ruby-forum.com/t/rails-oracle/99987/5 "2006-02-02T19:38:20Z")

</div>

“Robert H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> I have tried every connection string on the Rails site and it will not  
> connect. I can create a regular dbi script and connect and pull out  
> data.
> 
> If someone is using Rails + Oracle can you post the relevent portions  
> of your connection string? Please?!
> 
> Robert

Problem is, there are SO many ways to configure Oracle. The following  
simple thing works for me:

development:  
adapter: oci  
database: SID  
host: SID  
username: scott  
password: tiger

(I believe ‘database’ isn’t actually used.) Then I have this in  
tnsnames.ora:

SID =  
(DESCRIPTION =  
(ADDRESS\_LIST =  
(ADDRESS = (PROTOCOL = TCP)(HOST = host.domain.edu)(PORT = 1521))  
)  
(CONNECT\_DATA =  
(SERVICE\_NAME = sid)  
)  
)

On my Powerbook, HOST = localhost because I tunnel the database  
connection over SSH.

Steve
