jdk Tomcat MySql 环境变量地的配置
2007-08-24 22:00
585 查看
Tutorial
1. Preparation. 2
2. Install JDK. 3
3. Install TOMCAT. 5
4. Install MySQL & MySQLFront 10
5. Database Creating & How to import data. 12
6. Installing Project & Login. 12
7. Insert, update and delete data. 12
7.1 Insert 12
7.2 Update. 17
7.3 Delete. 19
1. Preparation
Make sure you have got all the files & software in your hand.
Here’s a list:
jdk-1_5_0_01-windows-i586-p.exe
jakarta-tomcat-5.0.28.exe
MySql.exe
MySQL-Front_Setup.exe
mysql-connector-java-3.1.11-bin.jar
2. Install JDK
Double click jdk-1_5_0_01-windows-i586-p.exe to install JDK
Set the environment variable:
Right click “我的电脑”==》属性==》高级==》环境变量==》新建...
3. Install TOMCAT
You can view 01-Tomcat-install&start.avi to learn how to install, tart and stop Tomcat.
Double click jakarta-tomcat-5.0.28.exe to install Tomcat.
Set connector port, user name and password.
Select the path of JVM
After starting Tomcat, there will be an icon on the system bar.
Right click mouse on the icon, and you will view something like configure
Click “Configure”, add “-Djava.home=d:/j2sdk1.4.2_04” in “Java Option”,
Testing
Before testing, you need to set the environment variable again:
Restart Tomcat, start up the IE browser and input:http://localhost:8080, then you will view the following information.
Notice
If you want to connect MySQL throw Tomcat, you must copy mysql-connector-java-3.1.11-bin.jar to Tomcat 5.0/common/lib, the restart Tomcat.
You can view 01-Tomcat-install&start.avi to learn how to install, start and stop Tomcat.
You can set the user name at will.
Set the server as localhost
Set the user as “root”.
Set the password at will.
Select database “test”.
You can view 02-MySQL-install.avi, 03-MySQLFront-install&start.avi to learn how to install and start MySQL & MySQLFront.
Add three fields named stuID, stuNM, stuAP in the new table.
Each field type should be “VarChar”, the length should be “255”
Then you can create a jsp file “Student_Insert.jsp”
The content is as following:
Student_Insert.jsp:
<!--
Project:Redcode 1.5
Name: Student_Insert.jsp
Author: Sijiangong
Date: 05/05/2006
Description: This page is used to insert data.
Modify Date: 06/05/2006
Modified By: Sijiangong
Description: Coding
-->
<%@ page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Insert</title>
</head>
<body>
<%
String strNumber = "0581490025"; //student number
String strName = "GaoXi"; //student name
String strApartment = "SoftwareSchool"; //student apartment
Connection con = null; //connection with the database
String strSql = null; //SQL querry
Statement stmt = null;
ResultSet rs = null;
%>
<%
try{
// to connect the database
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/student?user=root&password=123");
strSql = "INSERT INTO student VALUES
('"+strNumber+"','"+strName+"','"+strApartment+"')";
stmt = con.createStatement();
stmt.execute(strSql);
out.println("Data inserted");
stmt.close();
con.close();
} catch( Exception e ) {
System.out.println( e.toString() );
}
%>
</body>
</html>
Copy this file to “Tomcat 5.0/webapps/ROOT”, then input “http://localhost:8080/Student_Insert.jsp“ into the IE address bar, you will view the following page:
Check the database, you will find the newly inserted data.
The content is as following:
Student_Update.jsp:
<!--
Project:Redcode 1.5
Name: Student_Update.jsp
Author: Sijiangong
Date: 05/05/2006
Description: This page is used to update data.
Modify Date: 06/05/2006
Modified By: Sijiangong
Description: Coding
-->
<%@ page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Update</title>
</head>
<body>
<%
String strNumber = "0581490025"; //student number
String strName = "COOSEKI"; //student name
String strApartment = "SoftwareSchool"; //student apartment
Connection con = null; //connection with the database
String strSql = null; //SQL querry
Statement stmt = null;
ResultSet rs = null;
%>
<%
try{
// to connect the database
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/student?user=root&password=123");
strSql = "UPDATE student SET stuNM = '"+strName+"' WHERE stuID = '"+strNumber+"'";
stmt = con.createStatement();
stmt.executeUpdate(strSql);
out.println("Data updated");
stmt.close();
con.close();
} catch( Exception e ) {
System.out.println( e.toString() );
}
%>
</body>
</html>
Copy this file to “Tomcat 5.0/webapps/ROOT”, then input “http://localhost:8080/Student_Update.jsp“ into the IE address bar, you will view the following page:
The data has been changed
The content is as following:
<!--
Project:Redcode 1.5
Name: Student_Delete.jsp
Author: Sijiangong
Date: 05/05/2006
Description: This page is used to delete data.
Modify Date: 06/05/2006
Modified By: Sijiangong
Description: Coding
-->
<%@ page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Delete</title>
</head>
<body>
<%
String strNumber = "0581490025"; //student number
String strName = "GaoXi"; //student name
String strApartment = "SoftwareSchool"; //student apartment
Connection con = null; //connection with the database
String strSql = null; //SQL querry
Statement stmt = null;
ResultSet rs = null;
%>
<%
try{
// to connect the database
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/student?user=root&password=123");
strSql = "DELETE FROM student WHERE stuID = '"+strNumber+"'";
stmt = con.createStatement();
stmt.execute(strSql);
out.println("Data deleted");
stmt.close();
con.close();
} catch( Exception e ) {
System.out.println( e.toString() );
}
%>
</body>
</html>
Copy this file to “Tomcat 5.0/webapps/ROOT”, then input “http://localhost:8080/Student_Insert.jsp“ into the IE address bar, you will view the following page:
The record has been deleted
by Si :~
1. Preparation. 2
2. Install JDK. 3
3. Install TOMCAT. 5
4. Install MySQL & MySQLFront 10
5. Database Creating & How to import data. 12
6. Installing Project & Login. 12
7. Insert, update and delete data. 12
7.1 Insert 12
7.2 Update. 17
7.3 Delete. 19
1. Preparation
Make sure you have got all the files & software in your hand.
Here’s a list:
jdk-1_5_0_01-windows-i586-p.exe
jakarta-tomcat-5.0.28.exe
MySql.exe
MySQL-Front_Setup.exe
mysql-connector-java-3.1.11-bin.jar
2. Install JDK
Double click jdk-1_5_0_01-windows-i586-p.exe to install JDK
Set the environment variable:
Right click “我的电脑”==》属性==》高级==》环境变量==》新建...
variable name | variable value |
JAVA_HOME | C:/Java/jdk1.5.0_04 |
PATH | .;C:/Java/jdk1.5.0_04/bin |
CLASSPATH | .;C:/Java/jdk1.5.0_04 /lib/tools.jar; |
You can view 01-Tomcat-install&start.avi to learn how to install, tart and stop Tomcat.
Double click jakarta-tomcat-5.0.28.exe to install Tomcat.
Set connector port, user name and password.
Select the path of JVM
After starting Tomcat, there will be an icon on the system bar.
Right click mouse on the icon, and you will view something like configure
Click “Configure”, add “-Djava.home=d:/j2sdk1.4.2_04” in “Java Option”,
Testing
Before testing, you need to set the environment variable again:
variable name | variable value |
CATALINA_HOME | d:/Tomcat 5.0 |
CLASSPATH | .;%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tool.jar;%JAVA_HOME%/lib/tools.jar;%CATALINA_HOME%/common/lib/servlet-api.jar;%CATALINA_HOME%/common/lib/jsp-api.jar |
Notice
If you want to connect MySQL throw Tomcat, you must copy mysql-connector-java-3.1.11-bin.jar to Tomcat 5.0/common/lib, the restart Tomcat.
You can view 01-Tomcat-install&start.avi to learn how to install, start and stop Tomcat.
4. Install MySQL & MySQLFront
You can view 02-MySQL-install.avi, 03-MySQLFront-install&start.avi to learn how to install and start MySQL & MySQLFront.You can set the user name at will.
Set the server as localhost
Set the user as “root”.
Set the password at will.
Select database “test”.
You can view 02-MySQL-install.avi, 03-MySQLFront-install&start.avi to learn how to install and start MySQL & MySQLFront.
5. Database Creating & How to import data
You can view 04-MySQL-Database creating&import.avi to learn how to create database and how to import data. Here we use the database file “caesh”.6. Installing Project & Login
You can view 05-Installing Project & Login.avi to learn how to install and login into a project.7. Insert, update and delete data
7.1 Insert
Create a database named “student”, then create a new table named “student” too in the new database.Add three fields named stuID, stuNM, stuAP in the new table.
Each field type should be “VarChar”, the length should be “255”
Then you can create a jsp file “Student_Insert.jsp”
The content is as following:
Student_Insert.jsp:
<!--
Project:Redcode 1.5
Name: Student_Insert.jsp
Author: Sijiangong
Date: 05/05/2006
Description: This page is used to insert data.
Modify Date: 06/05/2006
Modified By: Sijiangong
Description: Coding
-->
<%@ page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Insert</title>
</head>
<body>
<%
String strNumber = "0581490025"; //student number
String strName = "GaoXi"; //student name
String strApartment = "SoftwareSchool"; //student apartment
Connection con = null; //connection with the database
String strSql = null; //SQL querry
Statement stmt = null;
ResultSet rs = null;
%>
<%
try{
// to connect the database
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/student?user=root&password=123");
strSql = "INSERT INTO student VALUES
('"+strNumber+"','"+strName+"','"+strApartment+"')";
stmt = con.createStatement();
stmt.execute(strSql);
out.println("Data inserted");
stmt.close();
con.close();
} catch( Exception e ) {
System.out.println( e.toString() );
}
%>
</body>
</html>
Copy this file to “Tomcat 5.0/webapps/ROOT”, then input “http://localhost:8080/Student_Insert.jsp“ into the IE address bar, you will view the following page:
Check the database, you will find the newly inserted data.
7.2 Update
Create a jsp file “Student_Update.jsp”The content is as following:
Student_Update.jsp:
<!--
Project:Redcode 1.5
Name: Student_Update.jsp
Author: Sijiangong
Date: 05/05/2006
Description: This page is used to update data.
Modify Date: 06/05/2006
Modified By: Sijiangong
Description: Coding
-->
<%@ page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Update</title>
</head>
<body>
<%
String strNumber = "0581490025"; //student number
String strName = "COOSEKI"; //student name
String strApartment = "SoftwareSchool"; //student apartment
Connection con = null; //connection with the database
String strSql = null; //SQL querry
Statement stmt = null;
ResultSet rs = null;
%>
<%
try{
// to connect the database
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/student?user=root&password=123");
strSql = "UPDATE student SET stuNM = '"+strName+"' WHERE stuID = '"+strNumber+"'";
stmt = con.createStatement();
stmt.executeUpdate(strSql);
out.println("Data updated");
stmt.close();
con.close();
} catch( Exception e ) {
System.out.println( e.toString() );
}
%>
</body>
</html>
Copy this file to “Tomcat 5.0/webapps/ROOT”, then input “http://localhost:8080/Student_Update.jsp“ into the IE address bar, you will view the following page:
The data has been changed
7.3 Delete
Create a jsp file “Student_Delete.jsp”The content is as following:
<!--
Project:Redcode 1.5
Name: Student_Delete.jsp
Author: Sijiangong
Date: 05/05/2006
Description: This page is used to delete data.
Modify Date: 06/05/2006
Modified By: Sijiangong
Description: Coding
-->
<%@ page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Delete</title>
</head>
<body>
<%
String strNumber = "0581490025"; //student number
String strName = "GaoXi"; //student name
String strApartment = "SoftwareSchool"; //student apartment
Connection con = null; //connection with the database
String strSql = null; //SQL querry
Statement stmt = null;
ResultSet rs = null;
%>
<%
try{
// to connect the database
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/student?user=root&password=123");
strSql = "DELETE FROM student WHERE stuID = '"+strNumber+"'";
stmt = con.createStatement();
stmt.execute(strSql);
out.println("Data deleted");
stmt.close();
con.close();
} catch( Exception e ) {
System.out.println( e.toString() );
}
%>
</body>
</html>
Copy this file to “Tomcat 5.0/webapps/ROOT”, then input “http://localhost:8080/Student_Insert.jsp“ into the IE address bar, you will view the following page:
The record has been deleted
by Si :~
相关文章推荐
- Xp下配置JSP环境:jdk+eclipse+tomcat+mysql
- ubuntu配置javaweb环境(jdk,tomcat,mysql,eclipse)
- CentOS下安装和配置MySQL-JDK-Tomcat-Nginx(个人官网环境搭建手册)
- CentOS下安装和配置MySQL-JDK-Tomcat-Nginx(个人官网环境搭建手册)
- [置顶] 腾讯云服务器中Ubuntu上的jdk,tomcat,MySQL的安装和环境配置
- linux配置环境 JDK+Tomcat+mysql
- jdk+tomcat+mysql环境配置
- 我的JSP环境的配置过程!(JDK+TOMCAT+MYSQL)
- Ubuntu - Edgy Eft 下安装配置Java开发环境(JDK 6 + Eclipse WTP + Tomcat + MySQL)
- 电脑所有开发JavaWeb所需环境配置(jdk Tomcat IDEA MySql)
- CentOS6.5环境下配置JDK+Tomcat+MySQL(附安装包)
- Ubuntu 13.10 下配置JDK+Tomcat+MySQL 搭建JSP开发环境
- ubuntu+Mysql+jdk+tomcat+apache环境配置
- 在 Linux RedHatEL6 环境下安装配置 JDK1.7 + Tomcat7.0 + MySQL5.6
- Ubuntu下的java开发环境配置(jdk+tomcat+mysql+myeclipse)
- Ubuntu64位(阿里云ECS)配置Java_Web环境(jdk,mysql,tomcat)
- ubuntu+Mysql+jdk+tomcat+apache环境配置
- centos搭建J2EE_CMS运行环境(jdk +tomcat +mysql配置)
- JSP环境的配置过程!(JDK+TOMCAT+MYSQL)
- JSP环境的配置过程(JDK+TOMCAT+MYSQL)