ActiveRecord/Oracle without Rails

Discussion in 'Ruby' started by Drew Olson, Feb 7, 2007.

  1. Drew Olson

    Drew Olson Guest

    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

    --
    Posted via http://www.ruby-forum.com/.
     
    Drew Olson, Feb 7, 2007
    #1
    1. Advertising

  2. Drew Olson

    Jan Svitok Guest

    On 2/7/07, Drew Olson <> wrote:
    > 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
     
    Jan Svitok, Feb 7, 2007
    #2
    1. Advertising

  3. Drew Olson

    Drew Olson Guest

    > 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Drew Olson, Feb 7, 2007
    #3
  4. Hi,

    On 2/7/07, Drew Olson <> wrote:
    > > 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?


    OCI.dll only? You need at least two files. OCI.dll and oraociei10.dll (Basic)
    or oraociicus10.dll (BasicLite).
     
    KUBO Takehiro, Feb 7, 2007
    #4
  5. Drew Olson

    Drew Olson Guest

    Takehiro Kubo wrote:
    > Hi,
    >
    > On 2/7/07, Drew Olson <> wrote:
    >> > 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?

    >
    > 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Drew Olson, Feb 7, 2007
    #5
  6. Hi,

    On 2/8/07, Drew Olson <> wrote:
    >
    > 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.
     
    KUBO Takehiro, Feb 7, 2007
    #6
  7. Drew Olson

    Drew Olson Guest

    Takehiro Kubo wrote:
    > 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Drew Olson, Feb 7, 2007
    #7
  8. Drew Olson

    Guest

    On Feb 7, 2:11 pm, Drew Olson <> wrote:
    > Takehiro Kubo wrote:
    > > 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
    >
    > --
    > Posted viahttp://www.ruby-forum.com/.


    Is a "service_name" the same as a SID??
    Thanks!
     
    , Mar 15, 2007
    #8
  9. 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
    --
    Posted via http://www.ruby-forum.com/.
     
    Senthil Krishnamoorthy, Aug 13, 2008
    #9
  10. Drew Olson

    Jesse Hu Guest

    [Note: parts of this message were removed to make it a legal post.]

    Pls install Oracle Instant Client
    http://www.oracle.com/technology/tech/oci/instantclient/index.html

    2008/8/14 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
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >



    --
    Cheers,
    Jesse
     
    Jesse Hu, Aug 26, 2008
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ari Brown

    ActiveRecord without Rails

    Ari Brown, Jul 31, 2007, in forum: Ruby
    Replies:
    4
    Views:
    157
    Reid Thompson
    Jul 31, 2007
  2. Reacher
    Replies:
    5
    Views:
    161
    Reacher
    Dec 18, 2007
  3. Xeno Campanoli
    Replies:
    1
    Views:
    139
    Xeno Campanoli
    May 29, 2008
  4. Xeno Campanoli
    Replies:
    1
    Views:
    133
    Xeno Campanoli
    Jun 3, 2008
  5. Mischa Berger
    Replies:
    3
    Views:
    212
    Mischa Berger
    Apr 15, 2009
Loading...

Share This Page