Http://hi.baidu.com/fpbest/blog/item/c9c7ce13df11e0e0c3ce790b.html
Step 1: download and installMicrosoft SQL Server 2000 Service Pack 4, That isSQL2000OfSP4Patch
The address is as follows:
Http://www.microsoft.com/downloads/zh-cn/details.aspx? Familyid = 8e2dfc8d-c20e-4446-99a9-b7f0127f8bc5 & displaylang = ZH-CN
Step 2: DownloadJDBCDriver,Decompress the package to any location ,:
Http://www.microsoft.com/downloads/zh-cn/details.aspx? Familyid = a737000d-68d0-4531-b65d-da0f2a735707
Step 3: CreateJavaProject, and thenWindows> preferences> JAVA> installed jres
Use the followingCodeTest:
Import java. SQL. connection;
Import java. SQL. drivermanager;
Import java. SQL. resultset;
Import java. SQL. statement;
Public class connectaccess {
Public static void main (string [] ARGs ){
Try {
Class. forname ("com. Microsoft. sqlserver. JDBC. sqlserverdriver ");
Connection con = drivermanager. getconnection ("JDBC: sqlserver: // localhost: 1433; databasename = pubs", "sa", "123456 ");
Statement stmt = con. createstatement ();
Resultset Rs into stmt.exe cutequery ("select fname, minit, lname from employee ");
While (Rs. Next ()){
System. Out. Print ("\ t fname:" + Rs. getstring (1 ));
System. Out. Print ("\ t minit:" + Rs. getstring (2 ));
System. Out. Print ("\ t lname:" + Rs. getstring (3 ));
System. Out. println ();
}
Rs. Close ();
Stmt. Close ();
Con. Close ();
} Catch (exception e ){
E. printstacktrace ();
}
}
}
Success! Haha !!!
Run the code before running it.SQLServer, don't forget it !!!