步骤如下:
一、下载SQLSERVER2000的jdbc驱动程序并安装。在微软站点就有这个驱动程序:http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/msdn-files/027/001/779/msdncompositedoc.xml&FinishURL=%2Fdownloads%2Frelease%2Easp%3FReleaseID%3D38312%26area%3Dsearch%26ordinal%3D1%26redirect%3Dno
二、启动JBuilder6.0。打开Tools-->Enterprise Setup-->DataBase Drivers-->Add--> New,然后命名"Microsoft SqlServer JDBC Driver",选择sqlserver2000--jdbc驱动的安装路径,加入三个jar文件(在安装目录的lib下面)。确定。
三、新建project,然后在project的属性中,选择Paths-->Required Libraries,添加"Microsoft SqlServer JDBC Driver"。
四、在程序上面添加:
import com.microsoft.*; [url=file://加][/url]// 加载类库
下面是我调试的一段代码,供参考:
void jButton1_actionPerformed(ActionEvent e) {
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=;DatabaseName=maxwell");
Statement stmt=conn.createStatement();
String sql="select * from employee";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
JOptionPane.showMessageDialog(null,rs.getString("name"),"员工名称",JOptionPane.YES_OPTION+JOptionPane.INFORMATION_MESSAGE );
}
}
catch(Exception ex)
{
System.err.println(ex.getMessage());
}
}