问题描述
我完成了此处设置OS X计算机,以允许我从Rails应用程序连接到Oracle.
在我的应用中设置database.yml
文件:
development:
adapter: oracle_enhanced
host: [SERVER IP ADDRESS]
database: [ORACLE INSTANCE SID]
username: xxx
password: yyy
encoding: utf8
也尝试使用域名.
在Rails控制台中尝试过...
>> con = ActiveRecord::Base.connection
但是它挂了很长时间,然后因错误而超时...
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'
[...]
有人在OS X上工作过并且知道如何解决这个问题吗?
您应该使用 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
更多注释在这里:
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时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!