Reprint
First, download the JDBC driver of SQLServer2000.
There is this driver in Microsoft Site:
WINDOW operating system
http://www.uncj.com/upload/files/ms_jdbc_setup.exe
Http://download.microsoft.com/download/3/0/F/30FF65D3-A84B-4B8A-A570-27366B2271D8/setup.exe
UNIX operating system MSSQLServer.tar
http://download.microsoft.com/download/3/0/F/30FF65D3-A84B-4B8A-A570-27366B2271D8 /MSSQLSERVER.TAR
Second, install JDBC
Execute the MS_JDBC_SETUP.EXE executable, everything just click Next, until the Finish button appears, complete the installation.
Note:
(1) MS_JDBC_SETUP default installation path is: C: / Program Files / Microsoft SQL Server 2000 Driver for JDBC
(2) This version (Version 2.2.0022) This only supports Microsoft SQL Server 2000 Driver for JDBC
(3) The three JAR files under the installation directory / lib / below is the JDBC driver core we want.
Msbase.jar
MSSQLServer.jar
Msutil.jar
Third, add three JAR files in the above (3) to the environment variable
Classpath:
D: /webserver/lib/msbase.jar; d: /webserver/lib/msqlser.jar; d: /webserver/lib/msutil.jar
Note: You can also save the above three files to the java_home / jre / lib / ext directory where your JVM is located, but it is not recommended.
Fourth, test
JSP file:
<% @ Page ContentType = "text / html; charset = GB2312"%>
<% @ Page Import = "java.sql. *"%>
<%
Class.Forname ("com.microsoft.jdbc.sqlserver.sqlserverdriver). NewInstance ();
String URL = "JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = HaIguan"
String User = "sa";
String password = ""
Connection conn = drivermanager.getConnection (URL, User, Password);
Statement Stmt = Conn.createStatement (ResultSet.Type_Scroll_Sensitive, ResultSet.concur_Updata);
String SQL = "SELECT * from XT_USER";
ResultSet RS = Stmt.executeQuery (SQL);
While (rs.next ())
{
%>
Your first field content is: <% = rs.getstring (1)%>
Your second field content is: <% = rs.getstring (2)%>
<%
}
%>
<% out.print ("Database operation is successful, congratulations");%> <%
Rs.close ();
Stmt.close ();
CONN.CLOSE ();
%>
body>
html>
V. Precautions
1. To ensure that your SQL service is started
2. You can log in normally in SQL or other users; (Some people use NT user management mode when installing SQL, there may be certain problems here)
3. The first configuration environment variable is best to restart the computer
4. Note JVM and Database start order: Start Database, then start the JVM machine.
Note: After stopping the web server, restart, it is best to have intervals of more than 10 seconds.
5. Pay attention to the network connectivity of the operating system
A. Start TCP / IP service
B. Configure the associated IP address, some people can use it automatically assign IP or configure IP, but the network is not possible to find IP
6. Some machines are in debugging that it is best to change the connection address localhost in (4) to the IP of the database server, which is also the reason for 5.