如何从非域注册的 Linux 机器使用 SQuirreL SQL 连接到 SQL Server?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9194888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:28:22  来源:igfitidea点击:

how to connect to SQL Server with SQuirreL SQL from non domain registered Linux box?

sql-serverlinuxdnssquirrel-sql

提问by gtludwig

I need to connect to a SQL 2008 R2 Server from my Linux box that's not registered in my company's domain. I'm trying to use SQuirreL SQL version 3.2.1. I downloaded Microsoft SQL Server JDBC Driver 3.0and assigned it to SQuirreL on the Drivers tab.

我需要从未在我公司域中注册的 Linux 机器连接到 SQL 2008 R2 服务器。我正在尝试使用 SQuirreL SQL 3.2.1 版。我下载了Microsoft SQL Server JDBC Driver 3.0并将其分配给 Drivers 选项卡上的 SQuirreL。

Now, when I try to create an Alias on SQuirreL, I select the SQL Server driver and adjust the URL. For credentials I use my domain registered username and password.

现在,当我尝试在 SQuirreL 上创建别名时,我选择 SQL Server 驱动程序并调整 URL。对于凭据,我使用我的域注册用户名和密码。

When I try to test the connection, I always get the same error:

当我尝试测试连接时,总是出现相同的错误:

<"database-name">: Logon failure for user '<"domain">\<"domain-user">'.

<"database-name">: 用户 '<"domain">\<"domain-user">' 登录失败。

How can I get this working? Thanks in advance!

我怎样才能让它工作?提前致谢!

采纳答案by gtludwig

I got rid of Microsoft SQL Server JDBC Driver and downloaded jTDSdriver. I tweaked a bit with it until I finally got a successful connection. The correct connection string was:

我摆脱了 Microsoft SQL Server JDBC 驱动程序并下载了jTDS驱动程序。我对它进行了一些调整,直到最终成功连接。正确的连接字符串是:

jdbc:jtds:sqlserver://<server_ip>:1433;databaseName=<instance_name>;domain=<domain_name>

回答by Peter L

I managed to connect to an SQL Server from SQuirrel on a linux box. Rough* steps ...

我设法从 Linux 机器上的 SQuirrel 连接到 SQL Server。粗略的*步骤...

  • You only need one of the jdbc jars from the MS download (copied to 'lib')
  • Must use SQL Server auth (not windows network auth)
  • SQL Server auth was already enabled on our db
  • Added a login 'jdoe'
  • Set jdoe default database to 'XxxDb'
  • Added a 'User Mapping' from jdoe to the desired database
  • Set up permission on the SQL Server for jdoe: 'Connect' and 'View any database'
  • Connection string: jdbc:sqlserver://SERVERNAME:1433;databaseName=XxxDb
  • 您只需要 MS 下载中的 jdbc jar 之一(复制到“lib”)
  • 必须使用 SQL Server 身份验证(不是 Windows 网络身份验证)
  • SQL Server 身份验证已在我们的数据库上启用
  • 添加了登录“jdoe”
  • 将 jdoe 默认数据库设置为 'XxxDb'
  • 添加了从 jdoe 到所需数据库的“用户映射”
  • 在 SQL Server 上为 jdoe 设置权限:“连接”和“查看任何数据库”
  • 连接字符串:jdbc:sqlserver://SERVERNAME:1433;databaseName=XxxDb

* May not need all as I poking around

* 可能不需要所有,因为我四处闲逛

回答by krebalo

The answer may be obsolete as I had the similar problem with SQuirrel SQL on MacOS 10.9.3 not on Linux box. The way Peter solved the problem inspired me. As the solution was not most straightforward I decided to put it here. Hope it helps someone.

答案可能已经过时,因为我在 MacOS 10.9.3 而非 Linux 机器上遇到了与 SQuirrel SQL 类似的问题。彼得解决问题的方式启发了我。由于解决方案不是最简单的,我决定把它放在这里。希望它可以帮助某人。

  1. Download latest Microsoft JDBC Driver 4.0 for SQL Server (tar.gz package)
  2. Extract only sqljdbc4.jar from the package
  3. Copy the jar file into Squirrel SQL (Contents->Resources->Java->Lib)
  4. Now Microsoft MSSQL Server JDBC Driver is available to create Alias
  5. Connection URL: jdbc:sqlserver://SERVERNAME;databaseName=DATABASENAME
  1. 下载最新的 Microsoft JDBC Driver 4.0 for SQL Server(tar.gz 包)
  2. 从包中仅提取 sqljdbc4.jar
  3. 将 jar 文件复制到 Squirrel SQL (Contents->Resources->Java->Lib)
  4. 现在 Microsoft MSSQL Server JDBC Driver 可用于创建别名
  5. 连接 URL:jdbc:sqlserver://SERVERNAME;databaseName=DATABASENAME

回答by ManuelJE

Another solution that worked for me. On a Windows desktop connecting to SQL Server 2008 R2, I had to follow these steps:

另一个对我有用的解决方案。在连接到 SQL Server 2008 R2 的 Windows 桌面上,我必须执行以下步骤:

  • copy the jtds-1.3.1.jarinto the SQuirrel SQL \lib directory
  • restart SQuirrel SQL and check that you see jTDS Microsoft SQLin the drivers list
  • make sure that in the driver configuration the Class Name specifies net.sourceforge.jtds.jdbc.Driver
  • use a connection string like this
  • jtds-1.3.1.jar复制到 SQuirrel SQL \lib 目录中
  • 重新启动 SQuirrel SQL 并检查您是否在驱动程序列表中看到jTDS Microsoft SQL
  • 确保在驱动程序配置中,类名指定net.sourceforge.jtds.jdbc.Driver
  • 使用这样的连接字符串

jdbc:jtds:sqlserver://<hostnameOrIp>:<port>/<databaseName>;instance=<instanceName>

jdbc:jtds:sqlserver://<hostnameOrIp>:<port>/<databaseName>;instance=<instanceName>

回答by technotux

Make sure the Microsoft jdbc driver is compatible with your java runtime version you're using,

确保 Microsoft jdbc 驱动程序与您使用的 Java 运行时版本兼容,

I was trying to use Driver 6.0 with java-9 and i got this error: ClassNotFoundException:javax.xml.bind.DatatypeConverter when i downgraded to version Java SE Runtime Environment 8u101 it connected without problems.

我试图将驱动程序 6.0 与 java-9 一起使用,当我降级到 Java SE 运行时环境 8u101 版本时,我收到了这个错误:ClassNotFoundException:javax.xml.bind.DatatypeConverter 它连接没有问题。

回答by R?zvan Flavius Panda

For you to connect to MS SQL Server you need to obtain the JDBC drivers:

要连接到 MS SQL Server,您需要获取 JDBC 驱动程序:

  • Download latest Microsoft JDBC Driver
  • Choose to download the .tar.gzpackage
  • Extract the package
  • In Squirrel-SQL click on Drivers tab on the left side of the window
  • Right click on Microsoft MSSQL Server JDBC Driverand choose Modify Driver...
  • Click on Extra Class Path
  • Click on Add
  • Browse to where sqljdbc41.jaris located (it should be under sqljdbc_4.1/enu/jre7/sqljdbc41.jar or similar) and click on Open
  • Click on OK
  • Now to the left of Microsoft MSSQL Server JDBC Driverin the Drivers list there should be a check mark which means that you installed the driver correctly
  • 下载最新的 Microsoft JDBC 驱动程序
  • 选择下载.tar.gz
  • 解压包
  • 在 Squirrel-SQL 中,单击窗口左侧的 Drivers 选项卡
  • 右键单击Microsoft MSSQL Server JDBC Driver并选择Modify Driver...
  • 点击 Extra Class Path
  • 点击 Add
  • 浏览到所在sqljdbc41.jar位置(应该在 sqljdbc_4.1/enu/jre7/sqljdbc41.jar 或类似目录下)并单击Open
  • 点击 OK
  • 现在Microsoft MSSQL Server JDBC Driver在驱动程序列表的左侧应该有一个复选标记,这意味着您正确安装了驱动程序

To connect to MS SQL Server:

要连接到 MS SQL Server:

  • Click on the Aliasestab on the left side of the window
  • Click on the +sign to Create a new Alias
  • Type a name for your new connection
  • In the URL text box paste the JDBC connection string (Azure gives this to you under connection strings for example)
  • enter username and password
  • click on test to see if the connection can be established
  • if test was successful then click on OKto finish creating your connection
  • 单击Aliases窗口左侧的选项卡
  • 点击+标志即可Create a new Alias
  • 输入新连接的名称
  • 在 URL 文本框中粘贴 JDBC 连接字符串(例如,Azure 在连接字符串下为您提供)
  • 输入用户名和密码
  • 点击测试,看是否可以建立连接
  • 如果测试成功,则单击OK以完成创建连接

If you are having any issues with connecting to Azure SQL database you might need to give access to your specific IP to connect to it or some similar access privileges.

如果您在连接到 Azure SQL 数据库时遇到任何问题,您可能需要授予对特定 IP 的访问权限以连接到它或一些类似的访问权限。