作者在 2011-03-21 13:59:52 发布以下内容
MicrosoftInternetExplorer402DocumentNotSpecified7.8Normal0
JTDS是一个开放源代码的100%纯Java的,用于JDBC 3.0驱动Microsoft SQL Server (6.5 ,7 ,2000和2005版本)和Sybase(10 ,11 ,12 ,15 版本)的驱动程序 。 JTDS是基于freetds的,并且是目前最快的生产准备JDBC驱动程序为SQL Server和Sybase 。 JTDS完全与JDBC 3.0兼容,支持只向前的,和可滚动/可更新的结果集(ResultSets)中并行(完全独立)语句,并且可实施所有databasemetadata和resultsetmetadata方法。
下载与安装
JTDS不需要特别的安装,只需要把JAR文件放在classpath路径中就可以了。
官方网站下载地址:http://sourceforge.net/project/showfiles.php?group_id=33291
官方网站首页:http://jtds.sourceforge.net/
用jtds连接SQL2000的方法
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class ByConnection {
public static Connection getConnection() {
String dbDriver = "net.sourceforge.jtds.jdbc.Driver";
String strConnection = "jdbc:jtds:sqlserver://localhost:1433/Test";
String user = "sa";
String password = "1";
Connection conn = null;
try {
Class.forName(dbDriver);
conn = DriverManager.getConnection(strConnection, user, password);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) {
Connection conn = ByConnection.getConnection();
try {
Statement st=conn.createStatement();
st.execute("insert into dept(name) values(\'5555\')");
st.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class ByConnection {
public static Connection getConnection() {
String dbDriver = "net.sourceforge.jtds.jdbc.Driver";
String strConnection = "jdbc:jtds:sqlserver://localhost:1433/Test";
String user = "sa";
String password = "1";
Connection conn = null;
try {
Class.forName(dbDriver);
conn = DriverManager.getConnection(strConnection, user, password);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) {
Connection conn = ByConnection.getConnection();
try {
Statement st=conn.createStatement();
st.execute("insert into dept(name) values(\'5555\')");
st.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}