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

柔情痞子 提交于 2019-11-29 02:41:26

问题


I'm trying to connect to a MS SQL Server 2005 Express database that is running on the local host from a java program.

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.

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

Any ideas?


回答1:


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:

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 FAQ on this.




回答2:


I would suggest MicSim's url:

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

Check this for jTDS Url Info.

This also has some interesting information to help troubleshoot jtds to sql express sorts of problems.

Good luck. Let us know how it goes.




回答3:


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.

e.g, c:>telnet servername 1433

to enable telnet client on windows

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




回答4:


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).

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



回答5:


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>


来源:https://stackoverflow.com/questions/1045958/what-is-the-jtds-jdbc-connect-url-to-ms-sql-server-2005-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!