当我的应用程序启动时,我收到ODBC错误:
ODBC::Error
S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
Rails.root: /var/www/html/TEST_APP
我使用Linux RHEL5 + apache和passenger + MSSQL Server 2008。
文件 database.yml :
development:
adapter: sqlserver
dsn: MSSQL
host: ip_address
port: 1433
mode: odbc
database: mydatabasename
username: myusername
password: mypassword
文件 freetds.conf :
[MSSQL]
host = ip_address
port = 1433
tds version = 8.0
client charset = UTF-8
文件 odbc.ini :
[MSSQL]
Driver=MSSQL
Description=ODBC connection via FreeTDS
Servername=MSSQL
Port=1433
Database=mydatabasename
Username=myusername
Password=mypassword
文件 odbc.ini :
[MSSQL]
Description = for mssql
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/lib64/libtdsS.so
FileUsage = 1
isql有效:
# isql -v MSSQL myusername mypassword
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
tsql也有效:
# tsql -S MSSQL -U myusername -P mypassword
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
我的gemlist:
gem 'rails', '4.1.8'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '4.1.0'
gem 'dbd-odbc'
gem 'dbi'
gem 'ruby-odbc'
日志:
ODBC::Error (S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to connect to data source):
activerecord-sqlserver-adapter (4.1.0) lib/active_record/connection_adapters/sqlserver_adapter.rb:343:in `initialize'
activerecord-sqlserver-adapter (4.1.0) lib/active_record/connection_adapters/sqlserver_adapter.rb:343:in `connect'
activerecord-sqlserver-adapter (4.1.0) lib/active_record/connection_adapters/sqlserver_adapter.rb:343:in `odbc_connect'
activerecord-sqlserver-adapter (4.1.0) lib/active_record/connection_adapters/sqlserver_adapter.rb:278:in `connect'
activerecord-sqlserver-adapter (4.1.0) lib/active_record/connection_adapters/sqlserver_adapter.rb:62:in `initialize'
activerecord-sqlserver-adapter (4.1.0) lib/active_record/sqlserver_base.rb:17:in `new'
activerecord-sqlserver-adapter (4.1.0) lib/active_record/sqlserver_base.rb:17:in `sqlserver_connection'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
activerecord (4.1.8) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.1.8) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.1.8) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
activerecord (4.1.8) lib/active_record/query_cache.rb:43:in `rescue in call'
activerecord (4.1.8) lib/active_record/query_cache.rb:32:in `call'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.8) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.8) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.8) lib/rails/engine.rb:514:in `call'
railties (4.1.8) lib/rails/application.rb:144:in `call'
passenger (5.0.6) lib/phusion_passenger/rack/thread_handler_extension.rb:85:in `process_request'
passenger (5.0.6) lib/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
passenger (5.0.6) lib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
passenger (5.0.6) lib/phusion_passenger/request_handler.rb:414:in `block (3 levels) in start_threads'
passenger (5.0.6) lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
Rendered /usr/local/rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.7ms)
Rendered /usr/local/rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.6ms)
Rendered /usr/local/rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.2ms)
Rendered /usr/local/rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (22.6ms)
rake db:migrate
在mydatabase中工作并创建表。
当我试图查看网站时,我在网站浏览器中看到此错误。
你知道问题出在哪里吗?