jdk Tomcat MySql 环境变量地的配置
来源:互联网 发布:abb机器人点焊编程 编辑:程序博客网 时间:2024/04/30 15:55
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-
MySql.exe
MySQL-Front_Setup.exe
mysql-connector-java-
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/jdk
PATH
.;C:/Java/jdk1.5.0_04/bin
CLASSPATH
.;C:/Java/jdk1.5.0_04 /lib/tools.jar;
3. Install TOMCAT
You can view 01-Tomcat-install&start.avi to learn how to install, tart and stop Tomcat.
Double click jakarta-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:/j2sdk
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
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-
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 “
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:
Description: This page is used to insert data.
Modify Date:
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:
Description: This page is used to update data.
Modify Date:
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:
Description: This page is used to delete data.
Modify Date:
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 :~
- jdk Tomcat MySql 环境变量地的配置
- 关于JDK,mysql,tomcat的环境变量配置
- JDK、tomcat环境变量的配置
- jdk、tomcat环境变量配置
- tomcat jdk环境变量配置
- JDK+tomcat 环境变量配置
- jdk,tomcat环境变量配置
- JDK+tomcat 环境变量配置
- JDK Tomcat 环境变量配置
- JDK+Tomcat 环境变量配置---
- JDK+tomcat 环境变量配置
- JDK+tomcat 环境变量配置
- jdk+tomcat环境变量配置
- tomcat+jdk环境变量配置
- JDK、Tomcat环境变量配置
- jdk+tomcat环境变量配置
- jdk 和 tomcat 的环境变量的配置
- JDK与Tomcat安装的环境变量配置
- 解读Oracle 11g提前发布的秘密
- 老三编码格式小工具1.0下载
- Web2.0催生广泛的蝴蝶效应
- 开篇之言
- 描述心境的歌 等一分钟
- jdk Tomcat MySql 环境变量地的配置
- Domain Specific Language(DSL)感想2
- 解读劳动合同法:仅两种情况辞职要交违约金
- 一段时间没写,竟然生疏了很多
- 急java.lang.NullPointerException是什么错误
- 再写一点数据库触发器
- linux 下 latex 的安装
- IE7.0破解方法!
- 完美打造安全的系统。