连接到SQL Server localdb JDBC [复制]

时间:2021-01-22 15:52:45

This question already has an answer here:

这个问题在这里已有答案:

I installed Microsoft SQL Server 2012 Express localdb on my system.

我在我的系统上安装了Microsoft SQL Server 2012 Express localdb。

After I created (and started) a Instance (Test) with an database (db1) I tried to connect with my java-Applikation.

在我创建(并启动)带有数据库(db1)的实例(测试)之后,我尝试连接我的java-Applikation。

The driver ist "com.microsoft.sqlserver.jdbc.SQLServerDriver".

驱动程序是“com.microsoft.sqlserver.jdbc.SQLServerDriver”。

My connection-string is "jdbc:sqlserver://(localdb)\Test;databaseName=db1;schema=db1;"

我的连接字符串是“jdbc:sqlserver://(localdb)\ Test; databaseName = db1; schema = db1;”

Error (truncated): java.net.UnknownHostException: '(localdb)' named instance 'Test' Check UDP Port 1434 Check if SQL Server browser-Service is started

错误(截断):java.net.UnknownHostException:'(localdb)'命名实例'测试'检查UDP端口1434检查SQL Server浏览器服务是否已启动

My .NET Framework Version is 4.0.2

我的.NET Framework版本是4.0.2

'SQLCMD.EXE -S(localdb)\Test' works fine.

'SQLCMD.EXE -S(localdb)\ Test'工作正常。

How can I solve this problem?

我怎么解决这个问题?

1 个解决方案

#1


5  

The Microsoft SQL Server JDBC driver does not support localDB. See the comment http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx#10250447

Microsoft SQL Server JDBC驱动程序不支持localDB。查看评论http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx#10250447

Krzysztof Kozielczyk - MSFT 22 Dec 2011 11:10 AM #

Krzysztof Kozielczyk - MSFT 22 Dec 2011 11:10 AM#

@Charles Stanton

Unfortunately JDBC driver doesn't support LocalDB at this moment and there is no easy workaround. The team is aware of this missing feature, but filing a connect item is always helpful for DCR tracking and prioritization.

不幸的是,JDBC驱动程序此时不支持LocalDB,并且没有简单的解决方法。团队了解这个缺失的功能,但提交连接项始终有助于DCR跟踪和优先级排序。

Thanks,

-Krzysztof

As explained by an answer in Connecting to SQL Server LocalDB using JDBC, it is possible to do this using the jTDS driver.

正如使用JDBC连接到SQL Server LocalDB中的答案所解释的那样,可以使用jTDS驱动程序执行此操作。

#1


5  

The Microsoft SQL Server JDBC driver does not support localDB. See the comment http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx#10250447

Microsoft SQL Server JDBC驱动程序不支持localDB。查看评论http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx#10250447

Krzysztof Kozielczyk - MSFT 22 Dec 2011 11:10 AM #

Krzysztof Kozielczyk - MSFT 22 Dec 2011 11:10 AM#

@Charles Stanton

Unfortunately JDBC driver doesn't support LocalDB at this moment and there is no easy workaround. The team is aware of this missing feature, but filing a connect item is always helpful for DCR tracking and prioritization.

不幸的是,JDBC驱动程序此时不支持LocalDB,并且没有简单的解决方法。团队了解这个缺失的功能,但提交连接项始终有助于DCR跟踪和优先级排序。

Thanks,

-Krzysztof

As explained by an answer in Connecting to SQL Server LocalDB using JDBC, it is possible to do this using the jTDS driver.

正如使用JDBC连接到SQL Server LocalDB中的答案所解释的那样,可以使用jTDS驱动程序执行此操作。