Provider Error

Discussion in 'Ruby' started by Daniel, Jun 6, 2006.

  1. Daniel

    Daniel Guest

    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
     
    Daniel, Jun 6, 2006
    #1
    1. Advertising

  2. Daniel

    ChrisH Guest

    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.rubyforge.org/) 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
     
    ChrisH, Jun 6, 2006
    #2
    1. Advertising

  3. Daniel

    Daniel Guest

    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.rubyforge.org/) 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, Jun 7, 2006
    #3
  4. Daniel

    ChrisH Guest

    Your welcome

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

    Cheers
     
    ChrisH, Jun 7, 2006
    #4
    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. BS
    Replies:
    3
    Views:
    2,063
    Alvin Bruney [MVP]
    Jun 17, 2004
  2. sloan
    Replies:
    5
    Views:
    1,515
    sloan
    Jun 4, 2006
  3. sloan
    Replies:
    1
    Views:
    514
    Chad Scharf
    Jul 3, 2007
  4. paul tomlinson
    Replies:
    2
    Views:
    163
    Peter James
    Jul 1, 2003
  5. Martin Franklin
    Replies:
    3
    Views:
    759
    Bob Barrows [MVP]
    Feb 25, 2005
Loading...

Share This Page