#1489 new
spk

Can't connect to Oracle database

Reported by spk | February 21st, 2011 @ 04:21 PM

I want to connect to a database on my server. How can I do it. (My way : DataMapper.setup(:default, 'oracle://username:password@host:1521/dbname') and it is not working for me. My environment is JRuby 1.6.0.RC1 and Rails 3 ubuntu 10.04
$ rails s => Booting WEBrick => Rails 3.0.3 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ~ Can't connect: oracle.thin://USERNAME:PASSWORD@HOST:1521/DBNAME Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4)))) (code: , sql state: , query: , uri: )
Exiting
/home/dev2/.rvm/gems/jruby-1.6.0.RC1@global/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:263:in with_connection': Can't connect: oracle.thin://USERNAME:PASSWORD@HOST:1521/DBNAME (DataObjects::SQLError) Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4)))) (code: , sql state: , query: , uri: )

I found the error is caused because of DataMapper.auto_upgrade!

$ rails c Loading development environment (Rails 3.0.3)
jruby-1.6.0.RC1 :001 > DataMapper::Logger.new($stdout, :debug)
=> #<DataMapper::Logger:0x1af4d51 @log=#<IO:0x10278c5>, @buffer=[], @init_args=[#<IO:0x10278c5>, :debug], @auto_flush=true, @level=0, @delimiter=" ~ "> jruby-1.6.0.RC1 :002 > DataMapper.setup(:default, 'oracle://Username:Password@host:1521/dbname')
=> #<DataMapper::Adapters::OracleAdapter:0x9300bf @normalized_uri=#, @name=:default, @options={"scheme"=>"oracle", "user"=>"Username", "password"=>"Password", "host"=>"host", "port"=>1521, "path"=>"/d", "query"=>nil, "fragment"=>nil, "adapter"=>"oracle"}, @field_naming_convention=DataMapper::NamingConventions::Field::Underscored, @resource_naming_convention=DataMapper::NamingConventions::Resource::UnderscoredAndPluralized> jruby-1.6.0.RC1 :003 > DataMapper.auto_upgrade!
~ Can't connect: oracle.thin://USERNAME:PASSWORD@HOST:1521/DBNAME Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4)))) (code: , sql state: , query: , uri: )
Exiting
/home/dev2/.rvm/gems/jruby-1.6.0.RC1@global/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:263:in with_connection': Can't connect: oracle.thin://USERNAME:PASSWORD@HOST:1521/DBNAME (DataObjects::SQLError) Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4)))) (code: , sql state: , query: , uri: )

Comments and changes to this ticket

  • spk

    spk February 21st, 2011 @ 04:26 PM

    This is how my model looks like

    class Loger
    include DataMapper::Resource

    property :id, Serial property :client_id, Integer property :created_at, DateTime property :updated_at, DateTime

    end
    DataMapper::Logger.new($stdout, :debug)

    DataMapper.setup(:default, 'oracle://SVCDEV:Rackspace1@10.7.76.140:1521/mooney')
    DataMapper.auto_upgrade!
    DataMapper.finalize

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages