Home > Database > Mysql Tutorial > body text

jTDS驱动兼容性问题

WBOY
Release: 2016-06-07 15:14:10
Original
1606 people have browsed it

Java连接SQL Server 2000数据库时,有两种方法: (1)通过Microsoft的JDBC 驱动 连接。此JDBC 驱动 共有三个文件,分别是mssqlserver.jar、msutil.jar和msbase.jar。但是Microsoft官网上已经找不到这些 驱动 ,其提供的sqljdbc.jar和sqljdbc4.jar并不支持SQ

Java连接SQL Server 2000数据库时,有两种方法:

(1)通过Microsoft的JDBC驱动连接。此JDBC驱动共有三个文件,分别是mssqlserver.jar、msutil.jar和msbase.jar。但是Microsoft官网上已经找不到这些驱动,其提供的sqljdbc.jar和sqljdbc4.jar并不支持SQL Server 2000。

驱动程序名称:com.microsoft.jdbc.sqlserver.SQLServerDriver(即下面的classforname
数据库连接URL:jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname(即下面的url

(2)通过jTDS驱动连接。下载地址:http://sourceforge.net/projects/jtds/files/jtds/

驱动程序名称:net.sourceforge.jtds.jdbc.Driver(即下面的classforname
数据库连接URL:jdbc:jtds:sqlserver://localhost:1433/dbname(即下面的url

采用第二种方法连接时,可能报错:

java.lang.UnsupportedClassVersionError: net/sourceforge/jtds/jdbc/Driver : Unsupported major.minor version 51.0

JDK的版本号对应:

J2SE 7 = 51 (0x33 hex),
J2SE 6.0 = 50 (0x32 hex),
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).

由此可知,上述错误是由于jTDS需要jdk7,而你使用的JDK版本不是jdk7。

解决方案:

(1)安装jdk7

(2)安装较低版本的jTDS(一般jTDS 3.x需要jdk7)

参考:

http://www.blogjava.net/guming123416/articles/28002.html

http://stackoverflow.com/questions/13403471/unsupported-version-error-using-jtds-with-scala

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template