を要求されたサービスを知っていない私は、最新のでのOracle DBに接続しようとしましたが、Windows 7のx64のPCのルビー-oci8の宝石ををoracle_enhanced以下のように、それは失敗しました:ルビー-oci8の:ORA-12514:TNS:リスナーは現在、接続記述子に
$ ruby oracle_db_connection.rb
oci8.c:654:in oci8lib_230.so: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (OCIError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.2-x64-mingw32/lib/oci8/oci8.rb:142:in `initialize'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:333:in `new'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:333:in `new_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:393:in `initialize'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:26:in `new'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:26:in `initialize'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/connection.rb:9:in `new'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/connection.rb:9:in `create'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:156:in `oracle_enhanced_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from C:/Ruby23-x64/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
from C:/Ruby23-x64/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:87:in `connection'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/model_schema.rb:230:in `table_exists?'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/primary_key.rb:97:in `get_primary_key'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/primary_key.rb:85:in `reset_primary_key'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/primary_key.rb:73:in `primary_key'
from C:in `primary_key'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation/finder_methods.rb:493:in `find_nth_with_limit'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation/finder_methods.rb:484:in `find_nth'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation/finder_methods.rb:127:in `first'
from C:in `first'
from oracle_db_connection.rb:30:in `<main>'
私はダウンロードして、Oracleインスタントクライアントをインストールして
**C:\Program Files\Oracle\instantclient_12_1**
にそれを解凍し、私は環境変数Tを追加しましたNS_ADMINはを指します。C:¥Program Files¥Oracle¥instantclient_12_1。 パスにTNS_ADMINを追加しました。シンプルなRubyスクリプト実行している場合
:
connection = ActiveRecord::Base.establish_connection(
adapter: 'oracle_enhanced',
database: 'my_db_sid',
host: 'my_db_host',
port: 1531,
username: 'username',
password: 'password'
)
puts connection.inspect
#class Customer < ActiveRecord::Base
# self.table_name = 'CUSTOMER'
#end
#
#puts "First: #{Customer.first}"
ここで間違っているものを上の任意のアイデア:私はCustomerテーブルへの呼び出しを削除すると
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: 'oracle_enhanced',
database: 'my_db_sid',
host: 'my_db_host',
port: 1531,
username: 'username',
password: 'password'
)
class Customer < ActiveRecord::Base
self.table_name = 'CUSTOMER'
end
puts "First: #{Customer.first}"
を、私は、接続オブジェクトを調べることができますか?このスクリプトは他のPCでは正常に動作しましたが、他のDBや環境では正常に動作しました。したがって、使用される設定は問題ありません。 ありがとうございます。
環境:
- のWindows 7×64ビットのRuby 2.3
- のActiveRecord-oracle_enhancedアダプタ(1.6.7)
- ルビーOCI8(2.2.2のx64-MINGW32)
:ActiveRecordは:: Base.establish_connection( アダプタ: 'oracle_enhanced'、 データベース: '// DB_HOST:1531/DB_SID'、 名: 'ユーザー名'、 パスワード: 'userpwd' )同じエラーで失敗しました:( – belgoros
さらに、渡された値には引用符を使用する必要があります。また、oracle enhanced gemのREADMEにも同じエラーがあります。https://github.com/rsim/oracle-enhanced – belgoros
Huh。 TNSPINGとの接続をテストしましたかhttp://www.orafaq.com/wiki/Tnsping? – rootatdarkstar