Title: WINDOWS2000 integrated mysql4.0.13 and Tomcat4.1.24 to build JSP environments
Author: hoxisoft (hoxisoft@263.net)
Date: 2003-06-20
Originally: In the vast Internet, there is no one in the latest mysql4.0.13 and the integrated configuration documentation of Tomcat4.1.24. In the rest of our own work, summarize the actual experience of the JSP environment and refer to previous version MySQL, Tomcat related configuration articles, write this configuration document. I hope to give the majority of beginners who like Java like me to make reference, in order to take a little more detours; the level is limited to the time, welcome ax!
table of Contents:
First, software preparation
Second, software installation
Third, the first configuration and test
Fourth, integrated configuration
Five, full line test
6. Supplementary description
Seven, thanks
Eight, explanation
Specific implementation steps:
First, software preparation:
Suppose you have a hard software environment that can run Win2000.
1.J2SDK1.4.1: Go to http://java.sun.com/j2se/1.4.1/download.html download;
2.Mysql4.0.13: to http://www.mysql.com download;
3.Tomcat4.1.24: to http://jakarta.apache.org/ download;
4.mm.mysql-2.0.4-bin.jar: to http://mysql.ihostunit.com/downloads/contrib/mm.mysql-2.0.4-bin.jar download;
Second, the software installation:
1. Install J2SDK:
Install according to the installation wizard (generally installed under C: /J2SDK1.4.1, easy to operate);
2. Install MySQL:
Install according to the installation wizard (select the installation directory to C: /, easy to operate; after the installation is successful, its path is: c: / mysql);
3. Install Tomcat:
Install according to the installation wizard (change the installation directory to c: /tomcat4.1, you will enter the password of Admin (system administrator);
4. Place the JDBC driver of MySQL:
Put mm.mysql-2.0.4-bin.jar files under C: /J2SDK1.4.0-RC/LIB (which should not do, it should not matter, mainly in system variables, but no A few people say it is good, so I will release it here);
Third, the first configuration and test:
For the first configuration of the software environment installed, and test its environment:
(1) Configuration - environment variable:
1. New system variable java_home, its value is: c: /j2sdk1.4.1 (if you don't press the above path installation, change to your installation path);
2. New system variable tomcat_home, its value is: c: / tomcat4 (if you don't press the above path installation, change to your installation path);
3. System variable ClassPath, added, its value is: c: / tomcat 4.1 / common / classes; c: / tomcat 4.1 / circume / lib
4. System variable ClassPath, added, its value is: C: /J2SDK1.4.0-RC/LIB/mm.mysql-2.0.4-bin;
(2) Test default service:
1. Please start Tomcat4.1 (in the start-program "to find the Apache Tomcat4.1 Run START Tomcat) service: Open the browser, type in the address bar: http: // localhost: 8080 Test: You can in the browser See the welcome interface of Tomcat. Description Tomcat works fine (note that the Tomcat default port is 8080, if there is other programs, please change);
2. Start the mysql service (MySQL service is started with the operating system by default, and Winmysqladmin.exe minimizes on the system tray):
Enter CMD, to the C: / MySQL / BIN directory, execute mysql, enter, normal, to output some welcome information, indicating that mysql works fine;
Fourth, integrated configuration:
Do the corresponding configuration for MySQL4 with Tomcat4, let them work together:
1. Copy mm.mysql-2.0.4-bin.jar to Tomcat's CommON / lib directory;
2. The test is normal; save the following code into Test.jsp to C: / tomcat 4.1 / webapps / root directory:
<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% java.sql.connection conn; java.lang.string strconn; class.forname ("org.gjt.mm.mysql.driver). Newinstance (); conn = java.sql.driverManager.getConnection ("JDBC: mysql: // LocalHost / Test", "root", "");%> <% - here is a TEST with MYSQL4 The library, the user and the password are the default root and air -%>
3. Enter http: // localhost: 8080 / test.jsp in the browser's address, if the blank page appears, that is, the mysql4 is integrated with Tomcat4;
Five, full line test:
Start Tomcat4.1;
2. Establish a database and table;
First establish a table in MySQL and insert a few data. SQL code is as follows: Create Database test; - Run Use Test; - Run Create Talbe User (ID INT (4) Auto_Increment Primary Key, Name Varchar (20)); - Run Insert Into User (Name) VALUES ('Test '); - Run OK, you have established a database TEST to create a table User, and a record is inserted.
3, display the record in the database;
Save the following code into test2.jsp to c: / tomcat 4.1 / webApps / root directory: <% @ page contenttype = "text / html; charset = GBK"%> <% @ page language = "java" import = " Java.sql. * "%> <% connection conn = null; class.forname (" org.gjt.mm.mysql.driver). NewInstance (); conn = java.sql.driverManager.getConnection ("JDBC: mysql : // localhost / test "," root "," "); if (conn == null) {system.out.println (" get conn error ");} Statement Stmt = conn.createstatement (); ResultSet RS_RESULT = NULL;%>
6. Supplementary description:
1. Suppose an item has a project in the E: / TEST / OA directory (including index.jsp and other JSP files and beans, such as WEB-INF / CLASSES / SERVLET, JAVABEAN); set Tomcat to support your project, open C: /TOMCAT4.1/conf/server.xml file, before " context>" before " context>", add
2. Start Tomcat4.1, enter http: // localhost: 8080 / OA in the browser's address, such as JSP and beans, etc., usually, you will generalize the content of your index.jsp / index.html file and display. Seven, thanks:
1. Thank Apache, MySQL organization, provides you with a good free application server and database;
2. Thank you for writing Tomcat3.x / Tomcat4. * Friends who configure documents, for your reference to this document today;
8. Description:
1. If you feel satisfied, I want to reprint or collect this article, I am very grateful, please indicate the author hoxisoft (hoxisoft@263.net)