Java 什么是 jTDS JDBC Connect URL to MS SQL Server 2005 Express
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1045958/
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
What is the jTDS JDBC Connect URL to MS SQL Server 2005 Express
提问by Ron Tuffin
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?
有任何想法吗?
采纳答案by MicSim
Are you sure it is the correct instance? SQL Express tends to install as named instance, like "localhost\SQLExpress", instead of a standard instance. So it would be something like:
您确定这是正确的实例吗?SQL Express 倾向于安装为命名实例,例如“localhost\SQLExpress”,而不是标准实例。所以它会是这样的:
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. You can also check the jTDS FAQon this.
否则首先尝试通过 OSQL.exe 工具检查您的连接。您还可以查看jTDS 常见问题解答。
回答by eric.christensen
I would suggest MicSim's url:
我建议 MicSim 的网址:
jdbc:jtds:sqlserver://localhost/Finance;instance=sqlexpress
Check thisfor jTDS Url Info.
检查这对JTDS地址信息。
Thisalso has some interesting information to help troubleshoot jtds to sql express sorts of problems.
这也有一些有趣的信息可以帮助解决 jtds 到 sql express 的各种问题。
Good luck. Let us know how it goes.
祝你好运。让我们知道怎么回事。
回答by Mohammed Rafeeq
To check whether TCP/IP is enabled and the port is not blocked you can use "telnet 1433". Until telnet doesn't connect, jTDS won't either.
要检查是否启用了 TCP/IP 并且端口没有被阻止,您可以使用“telnet 1433”。在 telnet 无法连接之前,jTDS 也不会。
e.g, c:>telnet servername 1433
to enable telnet client on windows
在 windows 上启用 telnet 客户端
回答by user2889171
SQL Server Browser service is disabled by default. 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. Example (no need to specify the sql server port).
默认情况下禁用 SQL Server Browser 服务。如果您正在开发 .Net 应用程序,则不需要启动 SQLBrowser,但如果您在 Java 中使用 JTDS,则需要启动它。示例(无需指定 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>
回答by VicXj
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>