根据以上所述,我尝试过:
establish_connection(:adapter => "jdbcmssql", :url => "jdbc:jtds:sqlserver://myserver:1433/mydatabase;domain='mynetwork';", :username => 'user', :password=>'pass' )
establish_connection(:adapter => "jdbcmssql", :url => 'jdbc:jtds:sqlserver://myserver:1433/mydatabase;domain="mynetwork";user="mynetwork\user"' )
establish_connection(:adapter => "jdbcmssql", :url => "jdbc:jtds:sqlserver://myserver:1433/mydatabase;domain='mynetwork';", :username=>'user' )
establish_connection(:adapter => "jdbcmssql", :url => "jdbc:jtds:sqlserver://myserver:1433/mydatabase;domain='mynetwork';integratedSecurity='true'", :username=>'user' )
..以及其他各种组合。
每次我得到:
net/sourceforge/jtds/jdbc/SQLDiagnostic.java:368:in `addDiagnostic': java.sql.SQLException: Login failed for user ''. The user is not associated with a trusted SQL Server connection. (NativeException)
如果我尝试没有用户信息:
establish_connection(:adapter => "jdbcmssql", :url => "jdbc:jtds:sqlserver://myserver/mydatabase")
我收到了这个回复:
net/sourceforge/jtds/jdbc/SQLDiagnostic.java:368:in `addDiagnostic': java.sql.SQLException: Login failed for user 'sa'. (NativeException)
任何提示?谢谢,
答案 0 :(得分:1)
您可以尝试一起删除域名,用户名和密码吗?我通过Java中的JTDS集成安全性连接到SQL Server,我唯一指定的是服务器和数据库,因为它从我登录的机器中获取了其余的凭据。实际上,您也可以省略1433端口,因为我认为它是SQL Server的标准端口,因此可以省略。
答案 1 :(得分:0)
文件ruby/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.6-java/lib/active_record/connection_adapters/jdbc_adapter.rb
第54行替换'sa'。
要解决此问题,请指定空白用户名,例如:
establish_connection(:adapter => "jdbcmssql", :url => "jdbc:jtds:sqlserver://myserver/mydatabase", :username=>'')
(非常感谢limc的回答让我朝这个方向看)