I'm having troubles connecting to a sqlserver database and I was hoping other sqlserver users might be able to help me figure out what I'm doing wrong. I can connect via freetds/odbc and tinytds with activerecord, but I would like to use datamapper and dm-sqlserver- adapter. Any advice on how I might resolve my difficulties would be most appreciated.
Lots of details below. Lonnie I'm trying to connect with this connection string: irb(main):003:0> DataMapper.setup(:default,'sqlserver:// lsmith:b@dp@ss@192.168.1.21:1433/ AdventureWorks;instance=MSSQLSERVER') => #<DataMapper::Adapters::SqlserverAdapter:0x10e8647 @name=:default, @resource_naming_convention=DataMapper::NamingConventions::Resource::UnderscoredAndPluralized, @normalized_uri=#<struct DataObjects::URI scheme="sqlserver", user="lsmith", password="b@dp@ss", host="192.168.1.21", port=1433, path="/AdventureWorks;instance=MSSQLSERVER", query={"scheme"=>"sqlserver", "user"=>"lsmith", "password"=>"b@dp@ss", "host"=>"192.168.1.21", "port"=>1433, "path"=>"/ AdventureWorks;instance=MSSQLSERVER", "query"=>nil, "fragment"=>nil, "adapter"=>"sqlserver"}, fragment=nil>, @field_naming_convention=DataMapper::NamingConventions::Field::Underscored, @options={"scheme"=>"sqlserver", "user"=>"lsmith", "password"=>"b@dp@ss", "host"=>"192.168.1.21", "port"=>1433, "path"=>"/ AdventureWorks;instance=MSSQLSERVER", "query"=>nil, "fragment"=>nil, "adapter"=>"sqlserver"}> irb(main):004:0> repository(:default).adapter.select('select GETDATE()') DataObjects::SQLError: Can't connect: jtds.sqlserver://lsmith:b%40dp %40ss@192.168.1.21:1433/AdventureWorks;instance=MSSQLSERVER? scheme=sqlserver&user=lsmith&password=b%2540dp %2540ss&host=192.168.1.21&port=1433&path=%252FAdventureWorks %253Binstance%253DMSSQLSERVER&query=&fragment=&adapter=sqlserver Server 192.168.1.21 has no instance named MSSQLSERVER? scheme=sqlserver&user=lsmith&password=b%2540dp %2540ss&host=192.168.1.21&port=1433&path=%252FAdventureWorks %253Binstance%253DMSSQLSERVER&query=&fragment=&adapter=sqlserver. (code: , sql state: , query: , uri: ) from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/ data_objects-0.10.3/lib/data_objects/pooling.rb:177:in `new' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/ data_objects-0.10.3/lib/data_objects/pooling.rb:172:in `new' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/ data_objects-0.10.3/lib/data_objects/pooling.rb:119:in `new' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/ data_objects-0.10.3/lib/data_objects/connection.rb:65:in `new' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/dm-do- adapter-1.1.0/lib/dm-do-adapter/adapter.rb:251:in `open_connection' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/dm- transactions-1.1.0/lib/dm-transactions/adapters/dm-do-adapter.rb:69:in `open_connection' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/dm-do- adapter-1.1.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection' from /home/lsmith/code/ruby/jruby/lib/ruby/gems/1.8/gems/dm-do- adapter-1.1.0/lib/dm-do-adapter/adapter.rb:33:in `select' from (irb):4 irb(main):005:0> It looks like the connection parameters are being appended to the end of the instance name, but I'm not sure if that's normal. I have also tried with an options hash, and I get the same results: DataMapper.setup(:default, { :adapter => 'sqlserver', :database => "AdventureWorks", :username => 'lsmith', :password => 'b@dp@ss, :host => '192.168.1.21', :path => "AdventureWorks;instance=MSSQLSERVER" }) Here are my gem and jruby versions: data_objects (0.10.3) datamapper (1.1.0) dm-aggregates (1.1.0) dm-constraints (1.1.0) dm-core (1.1.0) dm-do-adapter (1.1.0) dm-migrations (1.1.0) dm-serializer (1.1.0) dm-sqlserver-adapter (1.1.0) dm-timestamps (1.1.0) dm-transactions (1.1.0) dm-types (1.1.0) dm-validations (1.1.0) do-jdbc_sqlserver (1.2.4) do_jdbc (0.10.3) do_sqlserver (0.10.3) jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2011-03-26 6586) (OpenJDK Client VM 1.6.0_20) On a windows box, I have verified that there is a MSSQLSERVER instance listening on port 1433 on 192.168.1.21 udp port 1434 is also listening - which is the SQL Server Browser Service. C:\PortQryV2>PortQry.exe -n 192.168.1.21 -e 1434 -p UDP Querying target system called: 192.168.1.21 querying... UDP port 1434 (ms-sql-m service): LISTENING or FILTERED Sending SQL Server query to UDP port 1434... Server's response: ServerName CASTDB InstanceName MSSQLSERVER IsClustered No Version 10.0.1600.22 tcp 1433 ==== End of SQL Server query response ==== UDP port 1434 is LISTENING C:\PortQryV2> I can connect also via freetds/odbc: $ cat /etc/odbc.ini [CastitDB] Driver = FreeTDS Description = ODBC Connection via FreeTDS Trace = No Servername = CastDB Port = 1433 Database = AdventureWorks $ isql -v CastDB lsmith b@dp@ss +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> select GETDATE() +------------------------+ | | +------------------------+ | 2011-04-01 09:05:23.403| +------------------------+ SQLRowCount returns 1 1 rows fetched SQL> -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.