尝试从OS X上的Rails连接到Oracle时出错 [英] Error trying to connect to Oracle from Rails on OS X

查看:88
本文介绍了尝试从OS X上的Rails连接到Oracle时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了解决方案

您应该使用 host:行或 database:行,但不能同时使用两者. /p>

如果您有TNS条目,请使用数据库:行.

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

否则,请使用 host:格式.

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

更多注释在这里:

如何使用Oracle配置Ruby on Rails?

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?

解决方案

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?

这篇关于尝试从OS X上的Rails连接到Oracle时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆