[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Provider Error

Daniel

6/6/2006 1:29:00 PM

Hi,
I am Daniel, started to work on a application in Ruby. Im
rebuliding a application to ruby from MSAccess. since Im new to Ruby, I
have worked on a code to connect to PostgreSQL. But Im getting a error
message. Can someone help me out. I tired with someother options for
the database provider. I have pasted the code and the error message.

Code:

require 'dbi'
begin
# connect to the MySQL server
# dbh =
DBI::connect("PostgreSQL;localhost;inventory_dev","postgres","B4ckN3w!!")
#dbh=DBI.connect("driver=pg host=localhost port=5432
dbname=inventory_dev user=PostgreSQL password=vacn2002!")
#dbh = DBI.connect('localhost:PostgreSQL:inventory_dev','PostgreSQL',
'vacn2002')
#dbh=DBI.connect(driver="Pg",
database="host=localhost,dbname=inventory_dev")
#obj.login(user="PostgreSQL", pass="B4ckN3w!!")

dbh = DBI.connect("PostgreSQL","inventory_dev", "postgres",
"B4ckN3w!!")

#dbh = DBI.connect("DBI:pg:inventory_dev")

#dbh = DBI.connect("Driver={SQL
Server};Server=Intel266;Database=Inventory_DEV;Uid=sa;Pwd=vacn2002;")


# get server version string and display it
row = dbh.select_one("select * from UserList")
puts row
#puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
dbh.disconnect if dbh
end

Error:
>ruby DbConn.rb
c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:359:in `parse_url': Invalid Data
Source Name (DBI::InterfaceError)
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:226:in `_get_full_driver'
from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
from DbConn.rb:13
>Exit code: 1

3 Answers

Chris Hulan

6/6/2006 2:35:00 PM

0

Daniel wrote:
> Hi,
....
> require 'dbi'
> begin
....
> dbh = DBI.connect("PostgreSQL","inventory_dev", "postgres",
> "B4ckN3w!!")
....
> Error:
> >ruby DbConn.rb
> c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:359:in `parse_url': Invalid Data
> Source Name (DBI::InterfaceError)
> from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:226:in `_get_full_driver'
> from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
> from DbConn.rb:13
> >Exit code: 1

Looking at the DBI docs/examples (http://ruby-dbi.ruby...) it
appears your connect statement should be :
dbh = DBI.connect("DBI:Pg:inventory_dev", "postgres","B4ckN3w!!")

But for DBI to work the Postgress driver needs to be installed. You
can see what drivers are available by executing:
DBI.available_drivers.each {|dd| p dd}



Cheers

Daniel

6/7/2006 4:49:00 AM

0

Hi Chris,
Thanks for your reply. It worked perfectly. Hope to be
in touch with you.
Bye
Daniel.

ChrisH wrote:
> Daniel wrote:
> > Hi,
> ...
> > require 'dbi'
> > begin
> ...
> > dbh = DBI.connect("PostgreSQL","inventory_dev", "postgres",
> > "B4ckN3w!!")
> ...
> > Error:
> > >ruby DbConn.rb
> > c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:359:in `parse_url': Invalid Data
> > Source Name (DBI::InterfaceError)
> > from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:226:in `_get_full_driver'
> > from c:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
> > from DbConn.rb:13
> > >Exit code: 1
>
> Looking at the DBI docs/examples (http://ruby-dbi.ruby...) it
> appears your connect statement should be :
> dbh = DBI.connect("DBI:Pg:inventory_dev", "postgres","B4ckN3w!!")
>
> But for DBI to work the Postgress driver needs to be installed. You
> can see what drivers are available by executing:
> DBI.available_drivers.each {|dd| p dd}
>
>
>
> Cheers

Chris Hulan

6/7/2006 5:12:00 PM

0

Your welcome

BTW, I would be sure to change those passwords now that they are not
private! 9^)

Cheers