简体   繁体   English

什么是MS SQL Server 2005 Express的jTDS JDBC Connect URL

[英]What is the jTDS JDBC Connect URL to MS SQL Server 2005 Express

I'm trying to connect to a MS SQL Server 2005 Express database that is running on the local host from a java program. 我正在尝试从java程序连接到本地主机上运行的MS SQL Server 2005 Express数据库。

I have tried the same connect URL (below) that I used on another system (same jave code) that was running MS SQL Server 2000. But that does not work. 我尝试了在运行MS SQL Server 2000的另一个系统(相同的jave代码)上使用的相同连接URL(下面)。但这不起作用。

jdbc:jtds:sqlserver://127.0.0.1:1433/Finance

Any ideas? 有任何想法吗?

Are you sure it is the correct instance? 你确定它是正确的实例吗? SQL Express tends to install as named instance, like "localhost\\SQLExpress", instead of a standard instance. SQL Express倾向于安装为命名实例,如“localhost \\ SQLExpress”,而不是标准实例。 So it would be something like: 所以它会是这样的:

jdbc:jtds:sqlserver://127.0.0.1:1433/Finance;instance=<instance_name>

If this doesn't work, try dropping the instance name, and changing the port to the port used by the named instance: 如果这不起作用,请尝试删除实例名称,并将端口更改为命名实例使用的端口:

jdbc:jtds:sqlserver://127.0.0.1:<instance_port>/Finance

Else try to check your connectivity through OSQL.exe tool first. 否则首先尝试通过OSQL.exe工具检查您的连接。 You can also check the jTDS FAQ on this. 您也可以查看关于此的jTDS常见问题解答

I would suggest MicSim's url: 我会建议MicSim的网址:

jdbc:jtds:sqlserver://localhost/Finance;instance=sqlexpress

Check this for jTDS Url Info. 检查对JTDS地址信息。

This also has some interesting information to help troubleshoot jtds to sql express sorts of problems. 也有一些有趣的信息,以帮助解决jtds sql表达的各种问题。

Good luck. 祝好运。 Let us know how it goes. 让我们知道怎么回事。

To check whether TCP/IP is enabled and the port is not blocked you can use "telnet 1433". 要检查TCP / IP是否已启用且端口未被阻止,您可以使用“telnet 1433”。 Until telnet doesn't connect, jTDS won't either. 在telnet无法连接之前,jTDS也不会。

e.g, c:>telnet servername 1433

to enable telnet client on windows 在Windows上启用telnet客户端

http://social.technet.microsoft.com/wiki/contents/articles/910.how-to-enable-telnet-client-in-windows-7.aspx http://social.technet.microsoft.com/wiki/contents/articles/910.how-to-enable-telnet-client-in-windows-7.aspx

SQL Server Browser service is disabled by default. 默认情况下禁用SQL Server Browser服务。 If you're developing .Net apps, you do not need to start SQLBrowser, but if you're using JTDS in Java, you will need to have it started. 如果您正在开发.Net应用程序,则不需要启动SQLBrowser,但如果您在Java中使用JTDS,则需要启动它。 Example (no need to specify the sql server port). 示例(无需指定sql server端口)。

<property name="connection.url">jdbc:jtds:sqlserver://localhost/yourDbName;instance=SQLEXPRESS</property> 
<property name="connection.username">yourDbUser</property>
<property name="connection.password">yourDbPassword</property>

you can use this:: 你可以用这个::

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
    <property name="url" value="jdbc:sqlserver://localhost:1433;DatabaseName=Test1" />
    <property name="username" value="sa" />
    <property name="password" value="vic123" />
</bean>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM