Js|mysql|window: In the vast web of information, there is no new Mysql4.0.13 and Tomcat4.1.24 consolidated configuration document. In addition to their work, summed up their own JSP environment experience and reference to the previous version of MySQL, tomcat related configuration article, wrote this configuration document. I hope to give the same as I like the vast number of beginners in Java for reference, with a view to less to take detours; the level is limited and time is hasty, welcome treatise!
Directory:
First, software preparation
Second, the Software installation
Third, the first configuration and testing
Iv. Integrated Configuration
V. Full-line Testing
Vi. Supplementary Notes
Vii. Thank you.
Viii. description
Specific steps to achieve:
First, software preparation:
Let's say you have a hard and soft software environment that works Win2000.
1.j2sdk1.4.1: Download to http://java.sun.com/j2se/1.4.1/download.html;
2.mysql4.0.13: Download to http://www.mysql.com;
3.tomcat4.1.24: Download to http://jakarta.apache.org/;
4.mm.mysql-2.0.4-bin.jar: Download to Http://mysql.ihostunit.com/Downloads/Contrib/mm.mysql-2.0.4-bin.jar;
Second, the Software installation:
1. Install J2SDK:
Follow the installation wizard for installation (generally installed to c:j2sdk1.4.1, easy to operate);
2. Install MySQL:
Follow the installation Wizard to install (select the installation directory as C: for easy operation; After successful installation, its path is: C:mysql);
3. Install Tomcat:
Follow the installation Wizard to install (change the installation directory to C:TOMCAT4.) 1, you will be required to enter the admin (System Administrator) password;
4. To place the JDBC driver for MySQL:
Put the Mm.mysql-2.0.4-bin.jar file under the C:j2sdk1.4.0-rclib (in fact, where should be indifferent, mainly in the system variable to point to it, but a lot of people say put here, so I put it here);
Third, the first configuration and testing:
First configure and test the environment for the software environment that is installed above:
(1) configuration-Environment variables:
1. New system variable Java_home, the value is: c:j2sdk1.4.1 (if you do not follow the above path installation please change to your installation path);
2. New system variable Tomcat_home, the value is: C:TOMCAT4 (if you do not follow the above path installation please change to your installation path);
3. The system variable Classpath, adds, its value is: C:tomcat 4.1commonclasses; C:tomcat 4.1commonlib
4. System variable Classpath, add, its value is: C:j2sdk1.4.0-rclibmm.mysql-2.0.4-bin;
(2) Test default service:
1. Please start Tomcat4.1 (find Apache Tomcat4.1 run start Tomcat) service in Start-Program:
Open the browser and enter in the Address bar: http://localhost:8080 Check: You can see the Tomcat welcome interface in the browser at this time. Indicates that Tomcat is working properly (note that the Tomcat default port is 8080, if any other program is occupied, please change);
2. Start MySQL service (the MySQL service defaults to the operating system and has winmysqladmin.exe minimized on the system tray):
Enter CMD, to the C:mysqlin directory, the implementation of MySQL, carriage return, normal output Some welcome information, indicating that MySQL is working properly;
Iv. Integrated configuration:
Make the appropriate configuration for MYSQL4 and TOMCAT4 to work together for you:
1. Copy the Mm.mysql-2.0.4-bin.jar to the Common/lib directory of Tomcat;
2. Test whether the connection is normal, save the following code into the test.jsp to C:tomcat 4.1webappsROOT 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 the MYSQL4 default test library, where the user and password are the default root and null--%>
3, in the browser's address input http://localhost:8080/test.jsp if the operation, appear blank page, that means MYSQL4 and TOMCAT4 integration success;
Five, full line test:
1. Start Tomcat4.1;
2. Establishment of databases and tables;
First set up a table in MySQL, and insert as a few data. The SQL code is as follows:
Create DATABASE test;--Run
Use test;--Run
Create Talbe admin (id int (4) auto_increment primary key,name varchar (20));
INSERT into User (name) VALUES (' Test ');
OK, you've created the database test, created the table user, and inserted a record.
3, display the records in the database;
Save the following code into the test2.jsp to C:tomcat 4.1webappsROOT 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;
%>
<title> Testing </title><body>
<%
Rs_result=stmt.executequery ("SELECT * from user");
String Name;
while (Rs_result.next ())
{
Name=rs_result.getstring ("name");
%>
<%=Name%>
<%
}
Rs_result.close ();
Stmt.close ();
Conn.close ();
%>
</body>
4. Open your browser, enter http://localhost:8080/test.jsp in the address bar if run, the page will show test, that means read the database successfully;
Vi. Supplementary Notes:
1. Assume that there is already a project in the E:estoa directory (including index.jsp and other JSP files and beans, such as web-infclasses under the servlet, JavaBean);
Set Tomcat to support your project, open c:tomcat4.1confserver.xml file, add after "</Context>" before "</Host>"
<context path= "/oa" debug= "0" docbase= "E:estoa" reloadable= "true"/> and save.
Description: Context (representing a Web application): Docbase defines the path to the application; path represents the prefix of the URL for this Web application, so that the requested URL
It is important to http://localhost:8080/oa;reloadable this property, and if True, Tomcat automatically detects the application's/web-inf/lib
and/web-inf/classes directory changes, automatic load modifications or new beans and servlet, we can see the bean with the JSP changes without the restart of Tomcat;
2. Start Tomcat4.1, in the browser's address to enter HTTP://LOCALHOST:8080/OA, such as JSP and beans, etc. without errors, you will generally index.jsp/index.html
The contents of the file are executed and displayed.
Seven, thanks:
1. Thanks to Apache, MySQL organization, for everyone to provide such a good free application server and database;
2. Thank the friends who have previously written tomcat3.x/tomcat4.* configuration documents, for I wrote this document today for reference;
Viii. Description:
1. If you feel satisfied, want to reprint or collect this article, I am very grateful, but please note the author Hoxisoft (hoxisoft@263.net)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.