如何在MS SQL Server 2008 Express中使用MS JDBC驱动程序? [英] How can I use the MS JDBC driver with MS SQL Server 2008 Express?

查看:410
本文介绍了如何在MS SQL Server 2008 Express中使用MS JDBC驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的配置:


  • windows XP SP3

  • JDBC 2005

  • MS SQL Server 2008 Express,通过端口1433上的tcp / ip公开

  • 类路径中的sqljdbc.jar

  • windows XP SP3
  • JDBC 2005
  • MS SQL Server 2008 Express, exposed via tcp/ip on port 1433
  • sqljdbc.jar in class path

我试过:

try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
    con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/SQLEXPRESS2008;databaseName=Test;selectMethod=cursor", "sa", "");
}
catch (Exception e) {
    e.printStackTrace();
}

但它总是抛出异常:

java.sql.SQLException: No suitable driver

我也尝试过以下网址:

localhost:1433/SQLEXPRESS2008

localhost/SQLEXPRESS2008

localhost

相同的结果。
任何帮助?

Same results. Any help?

推荐答案

您的网址错误。

我不知道JDBC 2005是什么意思。当我查看微软网站时,我发现了一个名为 Microsoft SQL Server JDBC驱动程序2.0 你会想要那个 - 它包含许多修复和一些性能提升。

I don't know what you mean by "JDBC 2005". When I looked on the microsoft site, I found something called the Microsoft SQL Server JDBC Driver 2.0. You're going to want that one - it includes lots of fixes and some perf improvements. [edit: you're probably going to want the latest driver. As of March 2012, the latest JDBC driver from Microsoft is JDBC 4.0]

查看发行说明。对于此驱动程序,您需要:

Check the release notes. For this driver, you want:

URL:  jdbc:sqlserver://server:port;DatabaseName=dbname
Class name: com.microsoft.sqlserver.jdbc.SQLServerDriver

看来你的类名是正确的,但URL错了。

It seems you have the class name correct, but the URL wrong.

Microsoft在初始发布JDBC驱动程序后更改了类名和URL。您使用的URL与Microsoft的原始JDBC驱动程序一起使用,一个MS称为SQL Server 2000版本。但该驱动程序使用不同的类名。

Microsoft changed the class name and the URL after its initial release of a JDBC driver. The URL you are using goes with the original JDBC driver from Microsoft, the one MS calls the "SQL Server 2000 version". But that driver uses a different classname.

对于所有后续驱动程序,URL已更改为我在此处的表单。

For all subsequent drivers, the URL changed to the form I have here.

这是JDBC驱动程序的发行说明。

This is in the release notes for the JDBC driver.

这篇关于如何在MS SQL Server 2008 Express中使用MS JDBC驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆