来到微软的下载中心(downloads center) http://www.microsoft.com/downloads/
搜索字符串 JDBC
搜索结果中 SQL Server 2000 Driver for JDBC SP3就是Sqlserver 2000JDBC的驱动了
Title Release Date Popularity
SQL Server 2000 Driver for JDBC SP3
The Microsoft SQL Server 2000 Driver for JDBC is a Type 4 JDBC driver that provides highly scalable and reliable connectivity for the enterprise Java environment. This driver provides JDBC access to SQL Server 2000 through any Java-enabled applet, application, or application server.
JDBC连接SQLserver2000数据库类
import java.sql.*;
public class Database {
Connection conn;
Statement stmt;
ResultSet rs;
public Database() {
try {
Class.forName(“com.microsoft.jdbc.sqlserver.SQLServerDriver”).
newInstance();
} catch (ClassNotFoundException e) {
} catch (IllegalAccessException ex) {
} catch (InstantiationException ex) {
}
try {
String url =
“jdbc:microsoft:sqlserver://localhost:1433;databasename=testDb”;
String user = “”;
String password = “”;
conn = DriverManager.getConnection(url, user, password); //获得连接
stmt = conn.createStatement(); //获得执行SQL语言的容器
String sql = “select * from testTable”;
rs = stmt.executeQuery(sql); //获得结果集
while (rs.next()) {
System.out.println(rs.getString(1)); //拿到结果集中的第一列
}
} catch (SQLException e) {
}
}
}