Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > connecting to Oracle using OCI8 and DBI

Reply
Thread Tools

connecting to Oracle using OCI8 and DBI

 
 
Peter Bailey
Guest
Posts: n/a
 
      04-13-2009
Hi,
I need to access an Oracla database with Ruby. I've loaded OCI8 and DBI.
When I run a simple script to just check on the existence of an image in
the database, I get a DBI interface error, and, this:

Exception: Could not load driver (unitialized constant OCI8:river)

Can someone help?
Thanks a lot,
Peter
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
KUBO Takehiro
Guest
Posts: n/a
 
      04-14-2009
On Mon, Apr 13, 2009 at 9:35 PM, Peter Bailey <(E-Mail Removed)> wrote:
> Hi,
> I need to access an Oracla database with Ruby. I've loaded OCI8 and DBI.
> When I run a simple script to just check on the existence of an image in
> the database, I get a DBI interface error, and, this:
>
> Exception: Could not load driver (unitialized constant OCI8:river)


What version of ruby, ruby-dbi and ruby-oci8 do you use?
How did you install ruby-dbi and ruby-oci8?

 
Reply With Quote
 
 
 
 
Peter Bailey
Guest
Posts: n/a
 
      04-14-2009
Takehiro Kubo wrote:
> On Mon, Apr 13, 2009 at 9:35 PM, Peter Bailey <(E-Mail Removed)> wrote:
>> Hi,
>> I need to access an Oracla database with Ruby. I've loaded OCI8 and DBI.
>> When I run a simple script to just check on the existence of an image in
>> the database, I get a DBI interface error, and, this:
>>
>> Exception: Could not load driver (unitialized constant OCI8:river)

>
> What version of ruby, ruby-dbi and ruby-oci8 do you use?
> How did you install ruby-dbi and ruby-oci8?


Thanks,
I'm using Ruby 1.8.6. I did a gem install of dbi, so, presumably, it's
the latest. And, I downloaded and installed the latest version of oci8,
for Windows.

A colleague of mine suggested that, for my purposes, I can just use http
to query my database. So, I've done that and it works. But, I would like
to understand better how to actually get into the database, because, in
the future, I could foresee needing to actually pull files from it.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
KUBO Takehiro
Guest
Posts: n/a
 
      04-15-2009
Hi,

On Wed, Apr 15, 2009 at 12:09 AM, Peter Bailey <(E-Mail Removed)> wrote:
>>> Exception: Could not load driver (unitialized constant OCI8:river)


Did you manually edit dbi.rb?
The OCI8 Driver defines DBI:BD::OCI8:river, but not OCI8:river.

>> What version of ruby, ruby-dbi and ruby-oci8 do you use?
>> How did you install ruby-dbi and ruby-oci8?

>
> Thanks,
> I'm using Ruby 1.8.6. I did a gem install of dbi, so, presumably, it's
> the latest. And, I downloaded and installed the latest version of oci8,
> for Windows.


ruby-dbi 0.4.1?
ruby-oci8 2.0.1 or 1.0.5?

Could you tell me the result of the following command on the irb console?

require 'dbi'
DBI::VERSION
require 'oci8'
OCI8::VERSION
dbd_dr = DBI:BD.const_get(:OCI
dbd_dr:river.new
DBI.connect('dbi:OCI8:', 'username', 'password')

Copy and paste the output as follows:

c:\> irb
irb(main):001:0> require 'dbi'
=> true
irb(main):002:0> DBI::VERSION
=> "0.4.1"
irb(main):003:0> require 'oci8'
=> true
irb(main):004:0> OCI8::VERSION
=> "2.0.1"
irb(main):005:0> dbd_dr = DBI:BD.const_get(:OCI
=> DBI:BD::OCI8
irb(main):006:0> dbd_dr:river.new
=> #<DBI:BD::OCI8:river:0xf7a1bb3c>
irb(main):007:0> DBI.connect('dbi:OCI8:', 'username', 'password')
=> #<DBI:atabaseHandle:0xf7a13310 @driver_name="OCI8",
@trace_mode=nil, @convert_types=true,
@handle=#<DBI:BD::OCI8:atabase:0xf7a13220 @attr={},
@handle=#<OCI8:RUBY>>, @trace_output=nil>
irb(main):008:0>

 
Reply With Quote
 
Peter Bailey
Guest
Posts: n/a
 
      04-15-2009
DBI is version 0.1.1.
OCI8 is version 1.0.5
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
KUBO Takehiro
Guest
Posts: n/a
 
      04-15-2009
On Wed, Apr 15, 2009 at 10:34 PM, Peter Bailey <(E-Mail Removed)> wrote:
> DBI is version 0.1.1.
> OCI8 is version 1.0.5


Thanks.
What about other information I requested in my previous reply?

 
Reply With Quote
 
Peter Bailey
Guest
Posts: n/a
 
      04-15-2009
Takehiro Kubo wrote:
> On Wed, Apr 15, 2009 at 10:34 PM, Peter Bailey <(E-Mail Removed)> wrote:
>> DBI is version 0.1.1.
>> OCI8 is version 1.0.5

>
> Thanks.
> What about other information I requested in my previous reply?


F:\workflows\graphics>irb
irb(main):001:0> require 'dbi'
=> true
irb(main):002:0> require 'oci8'
=> true
irb(main):003:0> dbd_dr = DBI:BD.const_get(:OCI
=> OCI8
irb(main):004:0> dbd_dr:river.new
NameError: uninitialized constant OCI8:river
from (irb):4
irb(main):005:0> DBI.conect('dbi::OCI8:', 'orcauser', 'orca2user')
NoMethodError: undefined method `conect' for DBI:Module
from (irb):5
irb(main):006:0>
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
KUBO Takehiro
Guest
Posts: n/a
 
      04-15-2009
On Wed, Apr 15, 2009 at 11:26 PM, Peter Bailey <(E-Mail Removed)> wrote:
> Takehiro Kubo wrote:
>> On Wed, Apr 15, 2009 at 10:34 PM, Peter Bailey <(E-Mail Removed)> wrote:
>>> DBI is version 0.1.1.


The latest dbi is 0.4.1. You would use dbi bundled with One Click Ruby
Installer.

>>> OCI8 is version 1.0.5

>>
>> Thanks.
>> What about other information I requested in my previous reply?

>
> F:\workflows\graphics>irb
> irb(main):001:0> require 'dbi'
> =3D> true
> irb(main):002:0> require 'oci8'
> =3D> true
> irb(main):003:0> dbd_dr =3D DBI:BD.const_get(:OCI
> =3D> OCI8


I have thought that DBI:BD.const_get(:OCI would return DBI:BD::OCI8 a=
nd
it would raise an exception if DBI:BD::OCI8 is not defined. But it
returns OCI8
if DBI:BD::OCI8 is not found. I have misunderstood.

> irb(main):004:0> dbd_dr:river.new
> NameError: uninitialized constant OCI8:river
> =A0 =A0 =A0 =A0from (irb):4
> irb(main):005:0> DBI.conect('dbi::OCI8:', 'orcauser', 'orca2user')
> NoMethodError: undefined method `conect' for DBI:Module
> =A0 =A0 =A0 =A0from (irb):5
> irb(main):006:0>


You did a typo. Use 'connect' instead of 'conect'.
DBI.connect will be raise the following exception when using dbi 0.1.1
and oci8 1.0.5.
DBI::InterfaceError: Could not load driver (no such file to load
-- DBD/OCI8/OCI
Did you copy oci8.rb to DBD/OCI8/OCI8.rb?

You have two ways to use dbi and Oracle.
1. Use the latest dbi instead of 0.1.1.
Add "require 'rubygems'" prior to "require 'dbi'".
Otherwise,
2. Copy dbd/OCI8.rb to DBD/OCI8/OCI8.rb.

 
Reply With Quote
 
KUBO Takehiro
Guest
Posts: n/a
 
      04-15-2009
> You have two ways to use dbi and Oracle.
> 1. Use the latest dbi instead of 0.1.1.
> =A0 =A0Add "require 'rubygems'" prior to "require 'dbi'".
> Otherwise,
> 2. Copy dbd/OCI8.rb to DBD/OCI8/OCI8.rb.


Yet another way:
3. Use One-Click Installer 1.8.6-27 Release Candidate 2
The bundled dbi version is 0.2.2.
You have no need to copy dbd/OCI8.rb to DBD/OCI8/OCI8.rb.

 
Reply With Quote
 
Peter Bailey
Guest
Posts: n/a
 
      04-15-2009
Takehiro Kubo wrote:
>> You have two ways to use dbi and Oracle.
>> 1. Use the latest dbi instead of 0.1.1.
>> � �Add "require 'rubygems'" prior to "require 'dbi'".
>> Otherwise,
>> 2. Copy dbd/OCI8.rb to DBD/OCI8/OCI8.rb.

>
> Yet another way:
> 3. Use One-Click Installer 1.8.6-27 Release Candidate 2
> The bundled dbi version is 0.2.2.
> You have no need to copy dbd/OCI8.rb to DBD/OCI8/OCI8.rb.


Yeh, well, I don't see any one-click installer for 1.8.6-27, only 1.8.6.
And, that's what I've been using. And, if I go to these web sites and
choose the latest oci8 and dbi, I don't see why it just doesn't work.
So, for now, I'm just giving up. Thanks.

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ruby problem connecting to oracle using oci8 Dheeraj Gambhir Ruby 0 07-27-2009 11:11 AM
Using the DBI to connect to an Oracle server w/o connecting to adatabase Tim Perl Misc 8 12-15-2007 08:48 PM
Who is using DBI or oci8 in production systems Ben Edwards Ruby 1 05-18-2007 03:51 PM
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 230. Feyruz Perl Misc 4 10-14-2005 06:47 PM
DBI and DBI::Oracle packages configuration ulloa Perl 1 07-22-2004 05:52 PM



Advertisments