ActiveRecord/Oracle without Rails

D

Drew Olson

All -

I'm attempting to write a data validation program using ActiveRecord and
connecting to an Oracle 10g database. I've downloaded the ruby-oci8
package, double clicked it to install, and written a simple program
(shown below). However, when I run the program, I get a pop up with the
following error: This application has failed to start because OCI.dll
was not found. Re-installing the application may fix this problem. Also,
this is the error shown on the console after the application exits:

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/connection_
adapters/oracle_adapter.rb:685:in `oci_connection': Oracle/OCI libraries
could n
ot be loaded: 126: The specified module could not be found. -
c:/ruby/lib/ruby
/site_ruby/1.8/i386-msvcrt/oci8lib.so (LoadError)

Any ideas? I'm confused because when I doubled clicked the ruby-oci8
package, I know it placed oci8lib.so in
c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/oci8lib.so. I'm on a windows
box.

Thanks,
Drew

require 'rubygems'
require 'active_record'

ActiveRecord::Base::establish_connection(
:adapter=>"oci",
:host=>"*****",
:database=>"*****",
:user=>"*****",
:password=>"*****")

class Employee < ActiveRecord::Base
set_table_name "EMPLOYEE"
end

Employee.find:)all).each do |emp|
puts emp
end
 
J

Jan Svitok

All -

I'm attempting to write a data validation program using ActiveRecord and
connecting to an Oracle 10g database. I've downloaded the ruby-oci8
package, double clicked it to install, and written a simple program
(shown below). However, when I run the program, I get a pop up with the
following error: This application has failed to start because OCI.dll
was not found. Re-installing the application may fix this problem. Also,
this is the error shown on the console after the application exits:

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/connection_
adapters/oracle_adapter.rb:685:in `oci_connection': Oracle/OCI libraries
could n
ot be loaded: 126: The specified module could not be found. -
c:/ruby/lib/ruby
/site_ruby/1.8/i386-msvcrt/oci8lib.so (LoadError)

Any ideas? I'm confused because when I doubled clicked the ruby-oci8
package, I know it placed oci8lib.so in
c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/oci8lib.so. I'm on a windows
box.

Look for OCI.dll - it's a dependency for oci8lib.so. It should be 1.
in the oci8lib's dir, 2. somewhere on the $PATH. There are maybe more
options, for details see
http://msdn.microsoft.com/library/d...oc/base/dynamic-link_library_search_order.asp
 
D

Drew Olson

Look for OCI.dll - it's a dependency for oci8lib.so. It should be 1.
in the oci8lib's dir, 2. somewhere on the $PATH. There are maybe more
options, for details see

I was able to find OCI.dll by downloading the Oracle Instant Client. I
copied it to ruby/bin and now the previously mentioned error is gone.
Thanks for that. However, I'm seeing something new now. Any ideas?

c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:51:in `init': OCI Library
Initialization
Error (OCIError)
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:51
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `ge
m_original_require'
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re
quire'
from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_suppo
rt/dependencies.rb:495:in `require'
from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_suppo
rt/dependencies.rb:342:in `new_constants_in'
from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_suppo
rt/dependencies.rb:495:in `require'
from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_suppo
rt/core_ext/kernel/requires.rb:7:in `require_library_or_gem'
from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_suppo
rt/core_ext/kernel/reporting.rb:11:in `silence_warnings'
... 9 levels...
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d.rb:80
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `ge
m_original_require'
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `re
quire'
from models.rb:2
 
K

KUBO Takehiro

Hi,

I was able to find OCI.dll by downloading the Oracle Instant Client. I
copied it to ruby/bin and now the previously mentioned error is gone.
Thanks for that. However, I'm seeing something new now. Any ideas?

OCI.dll only? You need at least two files. OCI.dll and oraociei10.dll (Basic)
or oraociicus10.dll (BasicLite).
 
D

Drew Olson

Takehiro said:
Hi,



OCI.dll only? You need at least two files. OCI.dll and oraociei10.dll
(Basic)
or oraociicus10.dll (BasicLite).

Takehiro-

Thanks for your help! That seemed to solve the problem I was initially
having. I am getting another error now, but I'm assuming this has to do
with connecting to the database. The error is below. Does this mean I
have connected incorrectly? I read that I should not be using :database
within establish_connection. My method currently looks like so:

ActiveRecord::Base::establish_connection(
:adapter=>"oci",
:host=>"hostaddress/schema",
:user=>"user",
:password=>"pass")

Error:

c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:184:in `logon': ORA-12514:
TNS:listener d
oes not currently know of service requested in connect descriptor
(OCIError)
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:184:in `initialize'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/oracle_adapter.rb:584:in `new'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/oracle_adapter.rb:584:in `new_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/oracle_adapter.rb:620:in `initialize'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/oracle_adapter.rb:35:in `new'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/oracle_adapter.rb:35:in `oracle_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/oracle_adapter.rb:41:in `oci_connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/abstract/connection_specification.rb:262:in `send'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/abstract/connection_specification.rb:262:in
`connection_wi
thout_query_cache='
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/query_cache.rb:54:in `connection='
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/abstract/connection_specification.rb:230:in
`retrieve_conn
ection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/connection_adapters/abstract/connection_specification.rb:78:in
`connection'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/base.rb:1140:in `add_limit!'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/base.rb:1102:in `construct_finder_sql'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/base.rb:997:in `find_every'
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_recor
d/base.rb:418:in `find'
from models.rb:14
 
K

KUBO Takehiro

Hi,

ActiveRecord::Base::establish_connection(
:adapter=>"oci",
:host=>"hostaddress/schema",

It is not 'schema' but 'service_name'.
If your target database is Oracle Express Edition, it is 'XE'.

:host=>"hostaddress/XE",
c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:184:in `logon': ORA-12514:
TNS:listener d
oes not currently know of service requested in connect descriptor

The hostaddress's TNS listener doesn't know the service name.
 
D

Drew Olson

Takehiro said:
The hostaddress's TNS listener doesn't know the service name.

Takehiro -

I've got it working! Thanks for all your help, you've make it quite
easy.

-Drew
 
S

Senthil Krishnamoorthy

Hi Drew Olson ,

could you please help me out that where can i download the below dll's ?

oraociei10.dll
(Basic)
or oraociicus10.dll (BasicLite).


regards,
Senthil Krishnamoorthy
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top