Rails 3 - ActiveRecord :: ConnectionNotEstablished

时间:2013-02-19 21:01:45

标签: ruby-on-rails rails-activerecord jrubyonrails

我收到以下错误

  

的ActiveRecord :: ConnectionNotEstablished

在我更改了我的database.yml文件之后

在新创建的项目上:

development:
  adapter: jdbc
  driver: com.ibm.db2.jcc.DB2Driver
  url: localhost:50000/devdb
  host: localhost
  port: 50000
  database: devdb
  username: db2inst1
  password: mypass

这是框架跟踪:

activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
activerecord (3.2.12) lib/active_record/query_cache.rb:67:in `call'
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
activesupport (3.2.12) lib/active_support/callbacks.rb:408:in `_run__850430336__call__306646959__callbacks'
org/jruby/RubyBasicObject.java:1659:in `__send__'
org/jruby/RubyKernel.java:2086:in `send'
activesupport (3.2.12) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.12) lib/active_support/callbacks.rb:390:in `_run_call_callbacks'
org/jruby/RubyBasicObject.java:1659:in `__send__'
org/jruby/RubyKernel.java:2086:in `send'
activesupport (3.2.12) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.12) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.12) lib/rails/rack/logger.rb:16:in `call'
activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.12) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.12) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.12) lib/rails/engine.rb:479:in `call'
railties (3.2.12) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.12) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/home/gotqn/.rvm/rubies/jruby-1.7.2/lib/ruby/1.9/webrick/httpserver.rb:138:in `service'
/home/gotqn/.rvm/rubies/jruby-1.7.2/lib/ruby/1.9/webrick/httpserver.rb:94:in `run'
/home/gotqn/.rvm/rubies/jruby-1.7.2/lib/ruby/1.9/webrick/server.rb:191:in `start_thread'

您能告诉我我可以尝试解决这个问题或者帮助理解这条痕迹。我将非常感谢有关理解跟踪的一些文档或教程,因为我是rails的新手。

我正在使用:

  1. Ubuntu 12.04 LTC
  2. JRuby 1.7.2
  3. Rails 3.2.12
  4. DB2 C express 10.1

1 个答案:

答案 0 :(得分:0)

错误是由于在 database.yml 文件中指定了url时语法不正确。这是正确的方法:

development:
  adapter: jdbc
  driver: com.ibm.db2.jcc.DB2Driver
  url: jdbc:db2://localhost:50000/devdb
  host: localhost
  port: 50000
  database: devdb
  username: db2inst1
  password: mypass