Problem with Active Record and Oracle using oracle_enhanced adapter

Hi,

I’m having problem connecting activerecord and ruby with oracle_enhanced
adapter. I’m running this script directly in the machine with the DB.
This
is the example that I’m trying to run:

require ‘rubygems’
require ‘active_record’

ActiveRecord::Base.establish_connection(
:adapter => “oracle_enhanced”,
:username => “",
:password => "
",
:host => "127.0.0.1/
***”)

class Testing < ActiveRecord::Base
set_table_name “idm_test_tables”
set_primary_key “deptno”
end

temp = Testing.new

I’m receiving this:

env.c:257:in oci8lib.so: ORA-12560: TNS:protocol adapter error
(OCIError)
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:229:in initialize' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:692:innew’
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:692:in
new_connection' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:728:ininitialize’
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:in
new' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:inoracle_enhanced_connection’
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in
send' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:inconnection=’
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in
retrieve_connection' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:inconnection’
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1080:in
columns' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2363:inattributes_from_column_definition_without_lock’
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/locking/optimistic.rb:55:in
attributes_from_column_definition' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1922:ininitialize’
from test_activerecord_oracle.rb:19:in `new’
from test_activerecord_oracle.rb:19

Tool completed with exit code 1

It seems that I’m having problem with the connection but I’m already try
connecting with sqlplus with the same SID and it works. I’m on a windows
machine, with oracle 11g. Does anyone know what I’m doing wrong?

I found the problem, It don’t support this syntax:

:host => ‘/’

It must be in this way:

:host => ‘’ ,
:database => ‘’

so, this is the correct way:

ActiveRecord::Base.establish_connection(
:username => “pabloq”,
:password => “db345”,
:host => “127.0.0.1”,
:database => ‘’)

2008/5/13 Pablo Q. [email protected]n.invalid:

:database => ‘localhost/’ should work too.

2008/5/14 Pablo Q. [email protected]:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs