Step 1: ---- Install J2SDK:
To the Sun Official Site (http://java.sun.com) Download J2SDK installation file: J2SDK-1_4_2_04-windows-i586-p.exe, after downloading J2SDK; after installation, set environment variables: My computer --- Property - Advanced - Environment Variables;
Select --- System Variable (S): Set the Java_Home environment variable:
Click - New, enter: java_home in the variable name
Enter: D: / Java in the variable value
(Suppose J2SDK is installed under the directory D: / java, anyway is the J2SDK installation directory.)
Then --- OK, you have set a Java_Home environment variable.
Set the ClassPath environment variable:
Click - New, enter: ClassPath in the variable name
Enter: d: / java / lib; d: /java/lib/tt.jar; D: /java/lib/tools.jar
(Middle point "." And semicolons ";" essential.)
Then --- OK, you have set the ClassPath environment variable.
Set the PATH environment variable:
Click - New, enter: path in the variable name: Path
Enter: D: / java / bin in the variable value;
(Middle point "." And semicolons ";" essential.)
Then --- OK, you have set a Java_Home environment variable.
After the three environment variables are set, write a simple Java program to test whether J2SDK has been installed successfully:
Create a directory TEST in d: / next; then write the following procedure: public class test {public static void main (string args []) {system.out.println ("this is a test program");}}
Save the above program as file named Test.java, saved under the directory D: / Test.
Then open the command prompt window, CD to your TEST directory, and type the following command
Javac Test.java Java Test
At this point, if you see the THIS A Test Program. If you have successful installation,
If you don't print this sentence, you need to check your configuration carefully.
If the J2SDK is installed in the above, let's continue to install Tomcat:
Step 2: ---- Install Tomcat:
To Tomcat Official Site (http://www.apache.org/dist/jakarta/tomcat-4/) download Tomcat:
JAKARTA-TOMCAT-4.1.30.EXE, after downloading. (Such as installed under D: / Tomcat.)
After installation, set the environment variable: my computer --- Properties - Advanced - Environmental Variables;
Select --- System Variable (s):
Set the Catalina_Home environment variable:
Click - New, enter in the variable name: Catalina_home
Enter: D: / Tomcat in variable values
Then - determined that the Catalina_Home environment variable has been set.
Set the Catalina_Base environment variable:
Click --- New, type in the variable name: Catalina_Base
Enter: D: / Tomcat in variable values
Then - determined that the Catalina_Base environment variable is set. Then modify the ClassPath in the environment variable, add servlet.jar under CommON / lib under the Tomat installation directory to ClassPath,
The modified ClassPath is as follows:
ClassPath = D: / java / bin;; D: / java / lib; d: /java/lib/dt.jar; d: /java/lib/tools.jar; d: / tomcat / common / lib / servlet .jar
You can then start Tomcat, access http: // localhost: 8080 in IE, if you see the Tomcat's welcome page, the installation is successful.
If the Tomcat is installed in the top, continue to install the JSP to access the SQL Server 2000 driver:
Step 3: ---- Install JSP Access SQL Server 2000 driver:
Download drivers from Microsoft's website: SQL Server 2000 For JDBC driver, in Google, you can search in Google.
Then install it. (For example, the installation directory is d: / sqldriverforjdbc.)
Then you must use the three JAR files in the LIB directory in the installation directory:
Msbase.jar, mssqlserver.jar, msutil.jar Copy to the Tomcat directory in the common / lib directory, then modify the ClassPath in the environment variable, put the D: / Sqldriverfor JDBC / LIB / LIB / LIB / LIB / LIB / LIB / Msbase.jar; d: /sqldriverforjdbc/lib/mssqlser.jar; d: /sqldriverforjdbc/msutil.jar; append to ClassPath, modified ClassPath as follows:
ClassPath = D: / java / bin;; D: / java / lib; d: /java/lib/dt.jar; _d: /java/lib/tools.jar; d: / lubeetomcat / common / lib / servlet .jar; _d: /sqldriverforjdbc/lib/msbase.jar; d: /sqldriverforjdbc/lib/msqlser.jar; d: /sqldriverforjdbc/msutil.jar
Must restart Tomcat!
The purpose of this is that the JSP page does not have a problem that the SQL Server Driver class library does not appear during the compilation process.
Write a simple JSP code to test the connection SQL Server 2000
<% @ Page import = "java.lang. *, Java.io. *, Java.sql. *, Java.util. *" Contenttype = "text / html; charSet = GB2312"%>
<% Class.forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewInstance (); string url =" JDBC: Microsoft: SQLServer: // localhost: 1433; databasename = PUBS "; // Pubs for you String user database = "sa"; String password = "admin"; Connection conn = DriverManager.getConnection (url, user, password); Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String sql = " SELECT JOB_ID, JOB_DESC from Jobs "; ResultSet RS = Stmt.executeQuery (SQL); while (rs.next ()) {%> Your first field content is: <% = rs.getstring (1)%> < BR> Your second field content is: <% = rs.getstring (2)%>Enter: http:// localhost: 8080 / sql_test.jsp, if all configured success, will be displayed:
Your first field content is: 1 Your second field content: New Hire - Job Not Specified Your first field content is: 2 Your second field content is: Chief Executive Offer Your Part One field content is: 3 Your second field content is: Business Operations Manager Your first field content: 4 Your second field content is: Chief Financial Officier Your first field content: 5 Your second field content: Publisher Your first field content is: 6 Your second field content is: Managing Editor Your first field content: 7 Your second field content : Marketing Manager Your first field content is: 8 Your second field content is: Public Relations Manager Your first field content: 9 Your second field content is: acquisitions manager Your first Field content: 10 Your second field content: Productions Manager Your first field content: 11 Your second field content: Operations Manager Your first field content: 12 Your The second field content is: editor Your first field content: 13 Your second field content is: Sales Repesentative Your first field content is: 14 Your second field content is: Designer database Successful operation, congratulations on all the above contents related conditions: operating system: Window 2000 Server J2SDK version: J2SDK-1_4_2_04-Windows Tomcat version: Jakarta-Tomcat-4.1.30 Local Database: SQL Server 2000