rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
972 stars 557 forks source link

TinyTds::Error: closed connection #111

Closed toamitkumar closed 13 years ago

toamitkumar commented 13 years ago

bnl11538app002 current]$ rails console bt_sandbox Loading bt_sandbox environment (Rails 3.0.9) ruby-1.9.2-p290 :001 > ActiveRecord::Base.connection TinyTds::Error: closed connection

The stack trace:

from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:387:in `execute'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:387:in `block in connect'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:365:in `tap'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:365:in `connect'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:180:in `initialize'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:46:in `new'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-sqlserver-adapter-3.0.15/lib/active_record/connection_adapters/sqlserver_adapter.rb:46:in `sqlserver_connection'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `checkout_new_connection'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:191:in `block (2 levels) in checkout'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `loop'
from /opt/appdata00/client2/.rvm/gems/ruby-1.9.2-p290@hsi/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `block in checkout'
from /opt/appdata00/client2/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
toamitkumar commented 13 years ago

ruby 1.9.2 tiny_tds --> 0.4.3 sql server adapter --> 3.0.15

metaskills commented 13 years ago

Not much to go on here. You more than likely do not have TinyTDS/Adapter configured correction via a database.yml. Please do two things. Review the README for TinyTDS here https://github.com/rails-sqlserver/tiny_tds and setup a simple client in IRB and test your host/port/username/password/etc. Make sure you can get a connection. From there refer to the TinyTDS wiki page for information and general details https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds. You will need to isolate the problem and let me know.

toamitkumar commented 13 years ago

I had tried 'irb' and I was getting:

ruby-1.9.2-p290 :003 > client = TinyTds::Client.new(:username => 'mahauser', :password => 'm@h@user123!', :host => '10.32.49.7') TinyTds::Error: Adaptive Server connection failed

though telnet'ing works -->

bnl11538app002 current]$ telnet 10.32.49.7 1433 Trying 10.32.49.7... Connected to 10.32.49.7. Escape character is '^]'.

metaskills commented 13 years ago

At this point you need to debug FreeTDS/TinyTDS. Have you read the read me and wiki pages? For instance, are you using at least 0.82 of FreeTDS, checked your freetds.conf file for possible pitfalls mentioned on the wiki page. Perhaps even tried using 0.92 and compiling a local gem, mentioned on the read me too? Also, try using 0.4.5 of TinyTDS, moot if you compile locally and bind to 0.92 FreeTDS as our master branch is the upcoming 0.5.0.

toamitkumar commented 13 years ago

This helped. I used 'sm' framework to setup the machine which creates the freetds.conf file at the location --> /usr/local/bdsm/pkg/freetds/0.82/etc/ instead of /usr/local/etc

Such silly thing :)

metaskills commented 13 years ago

FreeTDS 0.92 was released last week and is the preferred. It removes any need for us to rely on a freetds.conf file. You do not even need to install FreeTDS via some system package manager since our git repo will allow you to build and statically link FreeTDS 0.92 into a native gem specific to your platform. See the read me if your interested.

Cheers.