Question

I am getting the following error

ActiveRecord::ConnectionNotEstablished

on new created project after I have changed my database.yml file like this:

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

This is the framework trace:

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'

Could you tell me what can I try to fix this or assist in understanding the trace. I will be grateful for some docs or tutorial about understanding the trace either as I am new in rails.

I am using:

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

Solution

The error was due to incorrect syntax when the url was specified in the database.yml file. This is the correct way:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top