Uninitialized constant OCI8::Driver

hi

I have loaded ruby-oci8 and dbi. I did gem install of dbi and oci8.
I getting an error "uninitialized constant OCI8::Driver" while
performing some commands which u can show below:-

irb(main):001:0> require 'dbi'
=> true
irb(main):002:0> DBI::VERSION
=> "0.4.5"
irb(main):003:0> require 'oci8'
=> true
irb(main):004:0> OCI8::VERSION
=> "2.1.5"
irb(main):006:0> dbd_dr = DBI::DBD.const_get(:OCI8)
=> OCI8
irb(main):007:0> dbd_dr::Driver.new
NameError: uninitialized constant OCI8::Driver
        from (irb):7
        from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):008:0> DBI.connect('dbi:OCI8:', 'username','password')
=> #<DBI::DatabaseHandle:0x214d550
@handle=#<DBI::DBD::OCI8::Database:0x214d580
@handle=#<OCI8:HR>, @attr={}>, @trace_output=nil, @trace_mode=nil,
@convert_type
s=true, @driver_name="OCI8">

please let me know what should i do now regarding this issue and how can
i connect to oracle database.

···

--
Posted via http://www.ruby-forum.com/.

Hi,

irb(main):006:0> dbd_dr = DBI::DBD.const_get(:OCI8)
=> OCI8
irb(main):007:0> dbd_dr::Driver.new
NameError: uninitialized constant OCI8::Driver
        from (irb):7
        from C:/Ruby200/bin/irb:12:in `<main>'

This error is not an issue because nobody define OCI8::Driver.
I guess that what you want to get is DBI::DBD::OCI8::Driver.
It is defined *after* DBI.connect('dbi:OCI8:', 'username','password') is
executed.

irb(main):008:0> DBI.connect('dbi:OCI8:', 'username','password')
=> #<DBI::DatabaseHandle:0x214d550
@handle=#<DBI::DBD::OCI8::Database:0x214d580
@handle=#<OCI8:HR>, @attr={}>, @trace_output=nil, @trace_mode=nil,
@convert_type
s=true, @driver_name="OCI8">

please let me know what should i do now regarding this issue and how can
i connect to oracle database.

You have already connected to oracle database.
Use the return value of DBI.connect as follows.

dbh = DBI.connect('dbi:OCI8:', 'username','password')
dbh.select_one('select * from dual')

···

On Wed, Aug 21, 2013 at 8:10 PM, tamanna garg <lists@ruby-forum.com> wrote: