OCIError: OCI Library Initialization Error and Unable to loa

Discussion in 'Ruby' started by Dheeraj Gambhir, Jul 22, 2009.

  1. Guys,

    I am putting this thing again and again, so you can guess that i need it
    badly.So, Please help me if you can.

    I am using:
    Ruby 1.8.6
    Oracle 9i
    Windows XP
    and i am done with "ruby ruby-oci8-0[1].1.13-mswin.rb"

    But when i run this code to check whether i am able to connect to the
    Oracle
    database server or not:

    ruby -r oci8 -e "OCI8.new('mlbread', 'mlbread', 'MLBD').exec('select *
    from bam_order.ec_invoice where order-id>2316027') do |r| puts r.join
    (' | '); end"

    Here mlbread=username, mlbread=password and MLBD=schema name

    It gives me the following error:

    C:\ruby>ruby -r oci8 -e "OCI8.new('mlbread', 'mlbread', 'MLBD').exec
    ('select * f
    rom bam_order.ec_invoice where order-id>2316027') do |r| puts r.join('
    | '); end
    "
    c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52:in `init': OCI Library
    Initialization
    Error (OCIError)
    from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52
    ******************************************************************

    For this code:

    require 'dbi'
    puts DBI.available_drivers
    dbh = DBI.connect('DBI:OCI8:MLBD', 'mlbread', 'mlbread')
    rs = dbh.prepare('select * from bam_order.ec_invoice where
    order_id=139920;')
    rs.execute
    while rsRow = rs.fetch do
    p rsRow
    #Alternative output: puts rsRow
    #Alternative output: pp rsRow
    end
    rs.finish
    dbh.disconnect

    Error is:

    C:\Program Files\Watir\examples>ruby oracletest.rb
    c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:329:in `load_driver': Unable to
    load drive
    r 'OCI8' (DBI::InterfaceError)
    from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:227:in
    `_get_full_driver'
    from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
    from oracletest.rb:5

    ******************************************************************

    For this code:

    require 'oci8'
    require 'dbi'

    connection = OCI8.new( 'mlbread', 'mlbread', 'MLBD')
    cursor = connection.exec('select * from bam_order.ec_invoice where
    order_id=139920;')
    while r = cursor.fetch()
    puts r.join(',')
    end
    cursor.close
    connection.logoff

    puts "and now using DBI"

    puts DBI.available_drivers
    db = DBI.connect('DBI:OCI8:MLBD', 'mlbread', 'mlbread')
    sql = "select * from bam_order.ec_invoice where order_id=139920;"

    dbh.select_all(sql) do | row |
    p row
    end

    Error is:

    C:\Program Files\Watir\examples>ruby oracletest1.rb
    c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52:in `init': OCI Library
    Initialization
    Error (OCIError)
    from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52
    from
    c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `ge
    m_original_require'
    from
    c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `re
    quire'
    from oracletest1.rb:1

    Please help me and let me know where i am wrong.

    Regards
    D G
    --
    Posted via http://www.ruby-forum.com/.
    Dheeraj Gambhir, Jul 22, 2009
    #1
    1. Advertising

  2. Dheeraj Gambhir

    rogerdpack Guest

    > ruby -r oci8 -e "OCI8.new('mlbread', 'mlbread', 'MLBD').exec('select *
    > from bam_order.ec_invoice where order-id>2316027') do |r| puts r.join
    > (' | '); end"
    >
    > Here mlbread=username, mlbread=password and MLBD=schema name
    >
    > It gives me the following error:
    >
    > C:\ruby>ruby -r oci8 -e "OCI8.new('mlbread', 'mlbread', 'MLBD').exec
    > ('select * f
    > rom bam_order.ec_invoice where order-id>2316027') do |r| puts r.join('
    > | '); end
    > "
    > c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52:in `init': OCI Library
    > Initialization
    > Error (OCIError)
    >         from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52


    What's on line 52? :)
    =r
    rogerdpack, Jul 23, 2009
    #2
    1. Advertising

  3. rogerdpack wrote:
    >> rom bam_order.ec_invoice where order-id>2316027') do |r| puts r.join('
    >> | '); end
    >> "
    >> c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52:in `init': OCI Library
    >> Initialization
    >> Error (OCIError)
    >> � � � � from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:52

    >
    > What's on line 52? :)
    > =r



    Line 52 of oci8 goes like "if DBI.const_defined?:)TypeUtil)"


    Thanks
    D G
    --
    Posted via http://www.ruby-forum.com/.
    Dheeraj Gambhir, Jul 27, 2009
    #3
    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. RTJ
    Replies:
    2
    Views:
    4,019
    Sanjay Rana
    Sep 27, 2006
  2. RTJ
    Replies:
    4
    Views:
    709
  3. Matt Ti

    create': ERROR (OCIError)

    Matt Ti, Mar 21, 2008, in forum: Ruby
    Replies:
    1
    Views:
    110
    Jesse Hu
    Mar 26, 2008
  4. Dheeraj Gambhir

    OCIError: OCI Library Initialization Error

    Dheeraj Gambhir, Jul 21, 2009, in forum: Ruby
    Replies:
    1
    Views:
    405
    Dheeraj Gambhir
    Jul 22, 2009
  5. Namit Jain
    Replies:
    0
    Views:
    233
    Namit Jain
    Aug 20, 2009
Loading...

Share This Page