The steps are as follows: 1. Download the SQLServer2000's JDBC driver and install it. There is this driver in Microsoft Site: http://msdn.microsoft.com/downloads/default.asp? URL = / / DownloadS / Sample.asp? URL = / MSDN-Files / 027/001/779 / MSDNCompositeoc.xml & FinishURL =% 2fdownloads% 2FRRELEASE% 2EASP% 3FRRELEASEID% 3D38312% 26are% 3DSearch% 26RDINAL% 3D1% 26Redirect% 3DNO
Second, start JBUILDER6.0. Open Tools -> Enterprise Setup -> Database Drivers -> Add -> New, then name "Microsoft SQLServer JDBC Driver", select SQLServer2000 - JDBC driver installation path, join three JAR files (in installation directory) Lib under the LIB). determine.
Third, create a new project, then in the property of Project, select Paths -> Required Libraries, add "Microsoft SQLServer JDBC Driver".
Fourth, add: Import com.microsoft. *; // Load class library
Here is my piece of code debug, for reference: 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 ()) {JOPANE.SHOWMESSAGEDIALOG (NULL, RS.GETSTRING ("Name"), "Name", JOTIONPANE.YES_OPTION JOTIONPANE.INFORMATION_MESSAGE);
} Catch (exception ex) {system.err.println (ex.getMessage ());}}