Problem with Active Record and Oracle using oracle_enhanced adapter

P

Pablo Q.

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 =3D> "oracle_enhanced",
:username =3D> "*******",
:password =3D> "******",
:host =3D> "127.0.0.1/****")



class Testing < ActiveRecord::Base
set_table_name "idm_test_tables"
set_primary_key "deptno"
end


temp =3D 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/l=
ib/active_record/connection_adapters/oracle_enhanced_adapter.rb:692:in
`new'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/l=
ib/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/l=
ib/active_record/connection_adapters/oracle_enhanced_adapter.rb:728:in
`initialize'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.1.0/l=
ib/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/l=
ib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:in
`oracle_enhanced_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connect=
ion_adapters/abstract/connection_specification.rb:291:in
`send'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connect=
ion_adapters/abstract/connection_specification.rb:291:in
`connection=3D'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connect=
ion_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/connect=
ion_adapters/abstract/connection_specification.rb:78:in
`connection'
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:in
`attributes_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:in
`initialize'
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?

--=20
Pablo A. Quir=F3s
 
P

Pablo Q.

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

:host =3D> '<address>/<SID>'

It must be in this way:

:host =3D> '<address>' ,
:database =3D> '<SID>'

so, this is the correct way:

ActiveRecord::Base.establish_connection(
:username =3D> "pabloq",
:password =3D> "db345",
:host =3D> "127.0.0.1",
:database =3D> '<SID>')


2008/5/13 Pablo Q. said:
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. Thi= s
is the example that I'm trying to run:

require 'rubygems'
require 'active_record'


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



class Testing < ActiveRecord::Base
set_table_name "idm_test_tables"
set_primary_key "deptno"
end


temp =3D 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:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:692:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:728:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:in
ction_adapters/abstract/connection_specification.rb:291:in
ction_adapters/abstract/connection_specification.rb:291:in
ction_adapters/abstract/connection_specification.rb:259:in
ction_adapters/abstract/connection_specification.rb:78:in
rb:1922:in
`initialize'
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?




--=20
Pablo A. Quir=F3s
 
J

Jesse Hu

:database =3D> 'localhost/<SID>' should work too.

2008/5/14 Pablo Q. said:
I found the problem, It don't support this syntax:

:host =3D> '<address>/<SID>'

It must be in this way:

:host =3D> '<address>' ,
:database =3D> '<SID>'

so, this is the correct way:

ActiveRecord::Base.establish_connection(
:username =3D> "pabloq",
:password =3D> "db345",
:host =3D> "127.0.0.1",
:database =3D> '<SID>')



/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:692:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:692:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:728:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:in
/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:46:in
ction_adapters/abstract/connection_specification.rb:291:in
ction_adapters/abstract/connection_specification.rb:291:in
ction_adapters/abstract/connection_specification.rb:259:in
ction_adapters/abstract/connection_specification.rb:78:in



--=20
Cheers,
Jesse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top