Ethan
Ethan

Reputation: 60099

Error trying to connect to Oracle from Rails on OS X

I went through all the steps described here to set up my OS X machine to allow me to connect to Oracle from a Rails app.

Set up the database.yml file in my app:

development:
  adapter: oracle_enhanced
  host: [SERVER IP ADDRESS]
  database: [ORACLE INSTANCE SID]
  username: xxx
  password: yyy
  encoding: utf8

Also tried it with the domain name.

Tried in Rails console...

>> con = ActiveRecord::Base.connection

But it hung for a long time then timed out with the error...

OCIError: ORA-12170: TNS:Connect timeout occurred
    from env.c:257:in oci8lib.so
    from /usr/local/lib/ruby/site_ruby/1.8/oci8.rb:229:in `initialize'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.2.0/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:184:in `new'
    from /usr/local/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.2.0/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:184:in `new_connection'

[...]

Has anyone gotten this working on OS X and knows how to solve this?

Upvotes: 2

Views: 1381

Answers (2)

Mark Harrison
Mark Harrison

Reputation: 304434

You should have either the host: line or the database: line, but not both.

Use the database: line if you have a TNS entry.

database: orcl    ## orcl is an entry in tnsnames.ora

Otherwise use the host: format.

host: dbhost.example.com/orcl    # dbhost: network address of the database host
                                 # orcl: database instance name

More notes here:

How to configure Ruby on Rails with Oracle?

Upvotes: 2

jiggy
jiggy

Reputation: 3826

If you have sqlplus installed with your Oracle client software, you should try connecting with that first to make sure the problem is your Rails config and not your connection info or the server itself.

Upvotes: 1

Related Questions